-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ci): publish to npm with provenance instead of bun publish #12
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 |
|---|---|---|
|
|
@@ -4,6 +4,11 @@ on: | |
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
| inputs: | ||
| ref: | ||
| description: Git tag to publish (e.g. v0.3.0) when re-running a release | ||
| required: true | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
@@ -31,15 +36,26 @@ jobs: | |
|
|
||
| npm-publish: | ||
| needs: release-please | ||
| if: ${{ needs.release-please.outputs.release_created }} | ||
| # Publish on a fresh release, or manually for a given tag via workflow_dispatch. | ||
| if: ${{ needs.release-please.outputs.release_created || github.event_name == 'workflow_dispatch' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write # required for npm provenance (OIDC) | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.inputs.ref || github.ref }} | ||
|
Comment on lines
46
to
+48
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.
Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/release-please.yml
Line: 46-48
Comment:
**Inconsistent action pinning**
`actions/setup-node` is pinned to a full commit SHA (good practice), but `actions/checkout@v4`, `oven-sh/setup-bun@v2`, and `actions/cache@v4` still use floating mutable tags. A compromised or accidentally force-pushed tag in any of those actions would run untrusted code in the same job that holds the `NPM_TOKEN` secret and the OIDC token. Pinning all actions to SHAs would make the supply-chain posture consistent.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
| - uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | ||
| with: | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org | ||
|
|
||
| - name: Cache Bun dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
|
|
@@ -54,7 +70,12 @@ jobs: | |
| - name: Build | ||
| run: bun run build | ||
|
|
||
| - name: Publish to npm | ||
| run: bun publish | ||
| # bun publish does not support npm provenance; build the tarball with bun | ||
| # and publish it via npm with --provenance (id-token: write enables OIDC). | ||
| - name: Pack tarball | ||
| run: bun pm pack | ||
|
|
||
| - name: Publish to npm (with provenance) | ||
| run: npm publish ./*.tgz --provenance --access public | ||
| env: | ||
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
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.
release-pleasefailsnpm-publishusesneeds: release-pleasewithoutif: always(). If therelease-pleasejob exits with a failure (transient API error, GitHub App token scope issue, etc.), GitHub Actions skips — not fails — any downstream job, bypassing theifcondition entirely. On aworkflow_dispatchrun this means the whole manual re-publish path silently does nothing, which is exactly the scenario this PR is designed to unblock.Adding
always()to the condition guards against this:This still correctly prevents a publish when a
pushrun completes without creating a release (release_createdis falsy andevent_nameispush).Prompt To Fix With AI