Skip to content

Commit 1dce602

Browse files
vigubikReplyclaude
andcommitted
ci: add manual public-npm release via OIDC trusted publishing
Promotes a chosen tag to public reply-cli via workflow_dispatch. Rebuilds from the tag, publishes with provenance (OIDC, no token). Flips the GitHub Release to full/latest; gated by the npm-public environment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e4d2aba commit 1dce602

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: publish-public
2+
3+
# Manually promote a tested tag to PUBLIC npm (unscoped `reply-cli`) using npm
4+
# OIDC trusted publishing — no NPM_TOKEN. Rebuilds from the selected tag,
5+
# publishes with provenance, then flips that tag's GitHub Release to full/latest.
6+
#
7+
# Two gates: the manual dispatch itself + the `npm-public` environment's required
8+
# reviewers (@reply-team/release-mergers). The workflow filename and environment
9+
# name are fixed by the npm trusted-publisher configuration and must not change.
10+
on:
11+
workflow_dispatch:
12+
inputs:
13+
tag:
14+
description: 'Existing tag to promote to public npm (e.g. v0.3.0)'
15+
required: true
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
publish:
22+
runs-on: ubuntu-latest
23+
environment: npm-public
24+
permissions:
25+
id-token: write # OIDC trusted publishing — no NPM_TOKEN needed
26+
contents: write # flip the GitHub Release to full/latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
ref: ${{ inputs.tag }} # rebuild from the exact tagged commit
31+
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 22
35+
registry-url: https://registry.npmjs.org
36+
37+
- name: Upgrade npm (trusted publishing needs >= 11.5.1)
38+
run: npm install -g npm@latest
39+
40+
- run: npm ci
41+
- run: npm run build
42+
43+
- name: Retarget package for public npm
44+
env:
45+
TAG: ${{ inputs.tag }}
46+
run: |
47+
VERSION="${TAG#v}"
48+
echo "Promoting ${TAG} -> reply-cli@${VERSION}"
49+
# Fail early if this version is already public (npm would 409 mid-publish).
50+
if npm view "reply-cli@${VERSION}" version >/dev/null 2>&1; then
51+
echo "::error::reply-cli@${VERSION} is already published to public npm"
52+
exit 1
53+
fi
54+
npm pkg set name=reply-cli # unscoped public name
55+
npm pkg delete publishConfig # drop the GitHub Packages registry
56+
npm version "${VERSION}" --no-git-tag-version --allow-same-version
57+
58+
- name: Publish to public npm with provenance
59+
run: npm publish --provenance --access public
60+
61+
- name: Promote the GitHub Release to full/latest
62+
env:
63+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: gh release edit "${{ inputs.tag }}" --prerelease=false --latest

0 commit comments

Comments
 (0)