Skip to content

Commit dfd92d5

Browse files
authored
ci: fix npm upgrade in publish job + add workflow_dispatch fallback (#3)
`npm install -g npm@latest` is broken on Node 22.22.2's bundled npm (missing 'promise-retry'), which broke the 0.1.3 publish. Switch to `npx -y npm@11.5.2 publish` — pinned for Trusted Publisher OIDC, no broken global install needed. Also add a workflow_dispatch trigger with a `tag` input so a publish can be re-run for an existing tag (e.g. v0.1.3) when CI flaked, without having to bump versions.
1 parent a0daf7d commit dfd92d5

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: Release
33
on:
44
push:
55
branches: [main]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Existing release tag to publish (e.g. v0.1.3). Used when a previous publish failed.'
10+
required: true
611

712
permissions:
813
contents: write
@@ -11,6 +16,7 @@ permissions:
1116

1217
jobs:
1318
release-please:
19+
if: ${{ github.event_name == 'push' }}
1420
runs-on: ubuntu-latest
1521
outputs:
1622
release_created: ${{ steps.release.outputs.release_created }}
@@ -23,23 +29,26 @@ jobs:
2329

2430
publish:
2531
needs: release-please
26-
if: ${{ needs.release-please.outputs.release_created == 'true' }}
32+
if: ${{ always() && (needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch') }}
2733
runs-on: ubuntu-latest
2834
permissions:
2935
contents: read
3036
id-token: write
3137
steps:
3238
- uses: actions/checkout@v4
3339
with:
34-
ref: ${{ needs.release-please.outputs.tag_name }}
40+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || needs.release-please.outputs.tag_name }}
3541
- uses: actions/setup-node@v4
3642
with:
3743
node-version: '22.x'
3844
registry-url: 'https://registry.npmjs.org'
3945
cache: npm
40-
- run: npm install -g npm@latest
4146
- run: npm ci
4247
- run: npm run lint
4348
- run: npm run typecheck
4449
- run: npm run build
45-
- run: npm publish --provenance --access public
50+
# Trusted Publisher OIDC needs npm >= 11.5.1. Node 22's bundled npm
51+
# is 10.x, and `npm install -g npm@latest` is currently broken on
52+
# 22.22.2 (missing 'promise-retry'). Use npx to invoke a known-good
53+
# npm version just for the publish step.
54+
- run: npx -y npm@11.5.2 publish --provenance --access public

0 commit comments

Comments
 (0)