Skip to content

Commit ff2a3d9

Browse files
Nick Ficanoclaude
andcommitted
ci: publish to npm on main when version changes
Renames the package to @agentruntimecontrolprotocol/arcp (scoped, public) and adds publishConfig + repository metadata for npm provenance. Adds .github/workflows/publish.yml that runs after the `test` workflow succeeds on main. It compares the local package.json version against the version on npm and publishes only when they differ. Uses NPM_TOKEN (repo secret) and OIDC for provenance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5c6ebea commit ff2a3d9

2 files changed

Lines changed: 107 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Publishes @agentruntimecontrolprotocol/arcp to npm after the `test` workflow
2+
# succeeds on main, but only when package.json `version` differs from the
3+
# version currently published on npm.
4+
#
5+
# Required repo configuration:
6+
# - Secret: NPM_TOKEN (npm automation token with publish rights to the
7+
# @agentruntimecontrolprotocol scope)
8+
# - Settings > Actions > General > Workflow permissions: "Read and write"
9+
# is NOT required; this workflow only needs id-token:write (set below)
10+
# for npm provenance.
11+
12+
name: publish
13+
14+
on:
15+
workflow_run:
16+
workflows: ["test"]
17+
types: [completed]
18+
branches: [main]
19+
workflow_dispatch:
20+
21+
concurrency:
22+
group: publish-${{ github.ref }}
23+
cancel-in-progress: false
24+
25+
jobs:
26+
publish:
27+
name: publish to npm
28+
runs-on: ubuntu-latest
29+
# Only run if the test workflow succeeded (or this was manually dispatched).
30+
if: >
31+
github.event_name == 'workflow_dispatch' ||
32+
(github.event.workflow_run.conclusion == 'success' &&
33+
github.event.workflow_run.head_branch == 'main')
34+
permissions:
35+
contents: read
36+
id-token: write # required for npm provenance
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
with:
41+
# For workflow_run, check out the exact commit that passed CI.
42+
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
43+
fetch-depth: 1
44+
45+
- name: Setup pnpm
46+
# pnpm/action-setup v4.0.0
47+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.0.0
48+
with:
49+
version: 9.15.0
50+
run_install: false
51+
52+
- name: Setup Node.js
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: "22"
56+
cache: "pnpm"
57+
registry-url: "https://registry.npmjs.org"
58+
59+
- name: Read local version
60+
id: local
61+
run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
62+
63+
- name: Read published version
64+
id: published
65+
run: |
66+
name=$(node -p "require('./package.json').name")
67+
# `npm view` exits non-zero if the package has never been published.
68+
published=$(npm view "$name" version 2>/dev/null || echo "")
69+
echo "version=$published" >> "$GITHUB_OUTPUT"
70+
71+
- name: Decide whether to publish
72+
id: decide
73+
run: |
74+
if [ "${{ steps.local.outputs.version }}" = "${{ steps.published.outputs.version }}" ]; then
75+
echo "publish=false" >> "$GITHUB_OUTPUT"
76+
echo "Local version (${{ steps.local.outputs.version }}) matches npm; skipping publish."
77+
else
78+
echo "publish=true" >> "$GITHUB_OUTPUT"
79+
echo "Publishing ${{ steps.local.outputs.version }} (npm has '${{ steps.published.outputs.version }}')."
80+
fi
81+
82+
- name: Install dependencies
83+
if: steps.decide.outputs.publish == 'true'
84+
run: pnpm install --frozen-lockfile
85+
86+
- name: Build
87+
if: steps.decide.outputs.publish == 'true'
88+
run: pnpm run build
89+
90+
- name: Publish
91+
if: steps.decide.outputs.publish == 'true'
92+
env:
93+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
94+
run: npm publish --access public --provenance

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
{
2-
"name": "arcp",
2+
"name": "@agentruntimecontrolprotocol/arcp",
33
"version": "0.1.0",
44
"description": "Reference TypeScript implementation of the Agent Runtime Control Protocol (ARCP) v1.0.",
55
"license": "Apache-2.0",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/agentruntimecontrolprotocol/typescript-sdk.git"
9+
},
10+
"homepage": "https://github.com/agentruntimecontrolprotocol/typescript-sdk#readme",
11+
"bugs": {
12+
"url": "https://github.com/agentruntimecontrolprotocol/typescript-sdk/issues"
13+
},
14+
"publishConfig": {
15+
"access": "public",
16+
"provenance": true
17+
},
618
"packageManager": "pnpm@9.15.0",
719
"type": "module",
820
"engines": {

0 commit comments

Comments
 (0)