-
Notifications
You must be signed in to change notification settings - Fork 1
ci: support npm trusted publishing recovery #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,19 @@ name: Release | |
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
| inputs: | ||
| publish: | ||
| description: Publish the current package version to npm | ||
| required: true | ||
| default: false | ||
| type: boolean | ||
|
|
||
| permissions: | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| release-please: | ||
|
|
@@ -16,6 +24,7 @@ jobs: | |
| steps: | ||
| - name: Create release PR or GitHub release | ||
| id: release | ||
| if: ${{ github.event_name == 'push' }} | ||
| uses: googleapis/release-please-action@v5 | ||
| with: | ||
| # Use a PAT to make the release PR trigger the normal pull_request CI. | ||
|
|
@@ -24,27 +33,29 @@ jobs: | |
| manifest-file: .release-please-manifest.json | ||
|
|
||
| - name: Checkout repository | ||
| if: ${{ steps.release.outputs.release_created }} | ||
| if: ${{ steps.release.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.publish) }} | ||
| uses: actions/checkout@v7 | ||
|
Comment on lines
+36
to
37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On a manual recovery, checkout uses the branch selected in the workflow UI rather than the tag for the failed release. If |
||
|
|
||
| - name: Setup pnpm | ||
| if: ${{ steps.release.outputs.release_created }} | ||
| if: ${{ steps.release.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.publish) }} | ||
| uses: pnpm/action-setup@v6 | ||
|
|
||
| - name: Setup Node.js 24 | ||
| if: ${{ steps.release.outputs.release_created }} | ||
| if: ${{ steps.release.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.publish) }} | ||
| uses: actions/setup-node@v7 | ||
| with: | ||
| node-version: 24 | ||
| cache: pnpm | ||
| registry-url: https://registry.npmjs.org | ||
|
|
||
| - name: Install dependencies | ||
| if: ${{ steps.release.outputs.release_created }} | ||
| if: ${{ steps.release.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.publish) }} | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Publish package to npm | ||
| if: ${{ steps.release.outputs.release_created }} | ||
| if: ${{ steps.release.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.publish) }} | ||
| run: pnpm publish --no-git-checks | ||
| env: | ||
| # Trusted Publishing uses the workflow's id-token permission. NPM_TOKEN | ||
| # remains available as a fallback for token-based npm authentication. | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A manual dispatch checks out whichever branch or tag the operator selects, while the skipped Release Please step provides no release commit to bind the run to. Selecting a feature branch or older tag with
publish=truecan therefore publish that ref's package contents instead of the contents of the existing GitHub release being recovered.