ci: add npm publish workflow - #2
Merged
Merged
Conversation
Publish to npmjs.com via Trusted Publishing (OIDC) with provenance, triggered by a published GitHub Release or manually via workflow_dispatch. A build job (typecheck, format check, lint, tests) gates the publish job. Publishing stays blocked by the prepublishOnly guard in package.json until the release preparation replaces it with the build script. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions workflow to publish the package to npmjs.com using npm Trusted Publishing (OIDC) on GitHub Release publication or manual dispatch, with a build/test gate before publishing.
Changes:
- Introduces
publish-package-to-npmjs.ymlwithrelease.publishedandworkflow_dispatchtriggers. - Adds a
buildjob to run install + typecheck/format/lint/tests before publishing. - Adds a
publish-to-npmjob that builds and publishes with--provenance --access publicusingid-token: write.
Comments suppressed due to low confidence (1)
.github/workflows/publish-package-to-npmjs.yml:46
actions/setup-nodeis pinned tov6in the publish job, but the repo’s CI workflow usesactions/setup-node@v7. Aligning on one major version reduces drift and avoids unexpected behavioral differences between CI and release publishing.
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+23
to
+27
| - uses: actions/checkout@v7 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: '22.x' | ||
| cache: 'npm' |
Comment on lines
+48
to
+52
| # Trusted publishing requires npm 11.5.1 or later | ||
| # https://docs.npmjs.com/trusted-publishers | ||
| - name: Update npm | ||
| run: npm install -g npm@latest | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
.github/workflows/publish-package-to-npmjs.yml, which publishes the package to npmjs.com:published, or manualworkflow_dispatchbuildjob gates the publish:npm ci→ typecheck → format check → lint → testspublish-to-npmjob publishes via Trusted Publishing (OIDC,id-token: write) with--provenance --access public; no tokens are storedMerging this is inert on its own: nothing runs until a Release is published (or the workflow is dispatched manually), and
npm publishremains blocked by theprepublishOnlyguard in package.json until release preparation replaces it with the build script. The npmjs side additionally requires registering this repo + workflow filename as a trusted publisher before the first publish can succeed.🤖 Generated with Claude Code