1818 name : Release Please
1919 runs-on : ubuntu-latest
2020 steps :
21- - uses : actions/checkout@v4
21+ - uses : actions/checkout@v7
2222
23- - uses : googleapis/release-please-action@v4
23+ - uses : googleapis/release-please-action@v5
2424 id : release
2525 with :
2626 config-file : release-please-config.json
@@ -31,19 +31,19 @@ jobs:
3131 # the exact bytes jsDelivr serves at gh@<major>/cdn/.
3232 - name : Checkout release PR branch
3333 if : ${{ steps.release.outputs.pr }}
34- uses : actions/checkout@v4
34+ uses : actions/checkout@v7
3535 with :
3636 ref : ${{ fromJSON(steps.release.outputs.pr).headBranchName }}
3737
3838 - name : Setup pnpm
3939 if : ${{ steps.release.outputs.pr }}
40- uses : pnpm/action-setup@v4
40+ uses : pnpm/action-setup@v6
4141 with :
4242 version : 9
4343
4444 - name : Setup Node
4545 if : ${{ steps.release.outputs.pr }}
46- uses : actions/setup-node@v4
46+ uses : actions/setup-node@v6
4747 with :
4848 node-version : 20
4949 cache : pnpm
@@ -76,32 +76,76 @@ jobs:
7676 gh release upload "${{ steps.release.outputs.tag_name }}" \
7777 cdn/claudius.iife.js cdn/claudius.css --clobber
7878
79- # On merge, publish to npm via Trusted Publishing (OIDC) — no long-lived
80- # NPM_TOKEN. Each package has a trusted publisher configured at npmjs.com
81- # matching this repo + this workflow filename (release-please.yml); the
82- # id-token: write permission above lets npm mint a short-lived token.
83- # Trusted Publishing needs npm >= 11.5.1 (newer than Node's bundled npm),
84- # so we upgrade npm first. Provenance is generated automatically. Runs
85- # against the default checkout (main at the released commit), which carries
86- # the version release-please just bumped.
79+ # ---------------------------------------------------------------------
80+ # Publish to npm via npm Trusted Publishing (OIDC). Tokenless: there is no
81+ # NPM_TOKEN secret. Each published package (claudius-chat-widget and
82+ # create-claudius) has a trusted publisher configured on npmjs.com, bound
83+ # to BOTH:
84+ # repo: PMDevSolutions/Claudius
85+ # workflow: release-please.yml (the filename of THIS workflow)
86+ # The job-level "id-token: write" permission lets npm exchange a GitHub
87+ # OIDC token for a short-lived publish token. Provenance is automatic.
88+ #
89+ # IMPORTANT: the trusted-publisher binding is keyed on this workflow's
90+ # FILENAME. Renaming this file, or running "npm publish" from a different
91+ # workflow, breaks publishing until each package's trusted publisher is
92+ # updated on npmjs.com to match the new filename.
93+ #
94+ # OIDC requires npm >= 11.5.1, newer than the npm bundled with Node 22, so
95+ # the steps below upgrade and verify npm first. Publishing runs against the
96+ # default checkout (main at the released commit), which carries the version
97+ # release-please just bumped.
98+ # ---------------------------------------------------------------------
8799 - name : Setup pnpm (npm publish)
88100 if : ${{ steps.release.outputs.release_created }}
89- uses : pnpm/action-setup@v4
101+ uses : pnpm/action-setup@v6
90102 with :
91103 version : 9
92104
93105 - name : Setup Node (npm publish)
94106 if : ${{ steps.release.outputs.release_created }}
95- uses : actions/setup-node@v4
107+ uses : actions/setup-node@v6
96108 with :
97109 node-version : 22
110+ # registry-url makes setup-node write the registry that OIDC mints its
111+ # short-lived token against (required for trusted publishing). The
112+ # "Sanitize npm config" step below removes the legacy always-auth key
113+ # and placeholder _authToken that setup-node also writes.
98114 registry-url : https://registry.npmjs.org
99115 cache : pnpm
100116 cache-dependency-path : widget/pnpm-lock.yaml
101117
102- - name : Upgrade npm for trusted publishing
118+ # setup-node's generated .npmrc (path exported as NPM_CONFIG_USERCONFIG)
119+ # carries a deprecated "always-auth" key (npm >= 11 warns: Unknown user
120+ # config "always-auth") and a placeholder _authToken that expands to empty.
121+ # Strip both so npm authenticates via OIDC instead of a bogus token; keep
122+ # the registry line so OIDC knows which registry to target.
123+ - name : Sanitize npm config for OIDC
103124 if : ${{ steps.release.outputs.release_created }}
104- run : npm install -g npm@latest
125+ run : |
126+ for f in "${NPM_CONFIG_USERCONFIG:-}" "$HOME/.npmrc"; do
127+ [ -n "$f" ] && [ -f "$f" ] || continue
128+ sed -i '/^always-auth=/d; /_authToken=/d' "$f"
129+ echo "Sanitized $f:"
130+ cat "$f"
131+ done
132+
133+ # Trusted Publishing (OIDC) requires npm >= 11.5.1, newer than Node 22's
134+ # bundled npm. Pin to npm 11 (not @latest) for reproducible runs, assert
135+ # the version, and prepend the freshly installed npm's bin dir to PATH so
136+ # the publish steps use it instead of Node's bundled npm.
137+ - name : Upgrade and verify npm for trusted publishing
138+ if : ${{ steps.release.outputs.release_created }}
139+ run : |
140+ npm install -g npm@^11
141+ NPM_GLOBAL_BIN="$(npm prefix -g)/bin"
142+ echo "$NPM_GLOBAL_BIN" >> "$GITHUB_PATH"
143+ NPM_VERSION="$("$NPM_GLOBAL_BIN/npm" --version)"
144+ echo "Resolved npm $NPM_VERSION from $NPM_GLOBAL_BIN"
145+ if [ "$(printf '%s\n' "11.5.1" "$NPM_VERSION" | sort -V | head -n1)" != "11.5.1" ]; then
146+ echo "::error::npm $NPM_VERSION is older than 11.5.1; trusted publishing (OIDC) requires >= 11.5.1" >&2
147+ exit 1
148+ fi
105149
106150 - name : Build and publish widget
107151 if : ${{ steps.release.outputs.release_created }}
0 commit comments