Skip to content

Commit 9813a30

Browse files
zhawtofclaude
andcommitted
fix(ci): publish via npx and tag prereleases explicitly
Two issues showed up running the trusted-publisher publish step: - `npm install -g npm@latest` races against the running bundled npm ("Cannot find module 'promise-retry'") because npm tries to overwrite its own files mid-install. Run the modern CLI via `npx` from its separate cache instead — no self-overwrite, same OIDC behavior. - npm 11+ refuses to publish a prerelease without `--tag`: "You must specify a tag using --tag when publishing a prerelease version." Derive the tag from the version's prerelease identifier so future prereleases (e.g. `-alpha.N`) land on the matching tag rather than getting bounced. Stable versions still publish to `latest` (default). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 128ce80 commit 9813a30

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,19 @@ jobs:
4747
- run: pnpm run build:clean
4848
if: ${{ steps.release.outputs.releases_created }}
4949

50-
# Trusted Publisher (OIDC) needs npm CLI >= 11.5.1; Node 22 ships with
51-
# npm 10.x, and pnpm <11.0.7 does not perform the OIDC exchange. So we
52-
# publish with npm from the upgraded CLI instead of `pnpm publish`.
53-
- run: npm install -g npm@latest
54-
if: ${{ steps.release.outputs.releases_created }}
55-
56-
- run: npm publish --provenance --access public
50+
# Trusted Publisher (OIDC) needs npm CLI >= 11.5.1; Node 22 ships
51+
# with npm 10.x. Run the modern CLI via `npx` from its separate
52+
# cache instead of `npm install -g npm@latest`, which races against
53+
# the running npm mid-install ("Cannot find module 'promise-retry'").
54+
# npm 11+ also requires an explicit --tag for prereleases.
55+
- name: Publish to npm
5756
if: ${{ steps.release.outputs.releases_created }}
57+
run: |
58+
version=$(node -p "require('./package.json').version")
59+
if [[ "$version" == *-* ]]; then
60+
tag="${version#*-}"
61+
tag="${tag%%.*}"
62+
npx -y npm@latest publish --provenance --access public --tag "$tag"
63+
else
64+
npx -y npm@latest publish --provenance --access public
65+
fi

0 commit comments

Comments
 (0)