Repository navigation
Harden npm release publishing #1
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: CodeQL | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| schedule: | ||
| - cron: "31 7 * * 1" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| concurrency: | ||
| group: codeql-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| analyze: | ||
| name: Analyze JavaScript and TypeScript | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
|
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7 | ||
| with: | ||
| node-version: 24.18.0 | ||
| package-manager-cache: false | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4 | ||
| with: | ||
| languages: javascript-typescript | ||
|
|
||
| - name: Build | ||
| uses: github/codeql-action/autobuild@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4 | ||
|
|
||
| - name: Analyze | ||
| uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4 |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ node_modules/ | |
| dist/ | ||
| coverage/ | ||
| *.tsbuildinfo | ||
| .release/ | ||
|
|
||
| .env | ||
| .env.* | ||
|
|
||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Release operations | ||
|
|
||
| `@pegma/audit` publishes only from a stable GitHub release. Merging a pull | ||
| request never publishes, and the workflow has no manual-dispatch or npm-token | ||
| fallback. | ||
|
|
||
| ## Required external configuration | ||
|
|
||
| Before the first release through this workflow: | ||
|
|
||
| - configure `@pegma/audit` on npm with the GitHub Actions trusted publisher | ||
| `pegma-dev/audit`, workflow `publish.yml`, environment `npm-publish`, and | ||
| allowed action `npm publish`; | ||
| - create the GitHub `npm-publish` environment. A second reviewer is not | ||
| required under Pegma's single-maintainer policy; | ||
| - create the repository Actions variable `RELEASE_ALLOWED_SIGNERS` containing | ||
| the reviewed Git SSH allowed-signers entry for the maintainer's release key; | ||
| this is public-key material, not a secret; and | ||
| - create an active tag ruleset targeting `v*` that prevents tag updates and | ||
| deletions and limits tag creation to the release maintainer. | ||
|
|
||
| Do not add `NODE_AUTH_TOKEN`, an npm automation token, or another credential | ||
| fallback. After one trusted-publisher release is verified, disable any | ||
| remaining traditional npm publish tokens. | ||
|
|
||
| ## Release procedure | ||
|
|
||
| The version in `packages/audit/package.json` is the release version. Change it | ||
| through an ordinary reviewed pull request and run the complete gate on Node 22 | ||
| and 24. | ||
|
|
||
| After that pull request is merged, create a signed annotated tag at the exact | ||
| `origin/main` commit, push the tag, verify the fetched tag, and only then | ||
| create the GitHub release with `--verify-tag`. Do not let GitHub create the tag | ||
| and never move or recreate a release tag. | ||
|
|
||
| The release workflow verifies that the tag: | ||
|
|
||
| - is a stable annotated `vX.Y.Z` tag signed by an allowed signer; | ||
| - matches the package version; | ||
| - points to the checkout and the GitHub release-event commit; and | ||
| - is contained in `origin/main`. | ||
|
|
||
| Its preparation job has no OIDC permission. It installs the reviewed npm | ||
| version without dependency caching, runs the full gate, builds and packs once, | ||
| smoke-tests the tarball from a clean consumer, records its SHA-1 and SHA-512 | ||
| integrity, and uploads the exact prepared artifact. | ||
|
|
||
| Only the `npm-publish` job receives `id-token: write`. It installs no | ||
| dependencies, verifies the prepared manifest and tarball hashes against the | ||
| release commit, and publishes that tarball with npm provenance. | ||
|
|
||
| ## Safe retry | ||
|
|
||
| The workflow is globally serialized. Re-run the failed release jobs against | ||
| the unchanged tag: | ||
|
|
||
| - an absent version is published; | ||
| - an existing version with identical `dist.integrity` is verified and skipped; | ||
| - a different integrity, or any registry error other than `E404`, stops the | ||
| release. | ||
|
|
||
| Never unpublish and reuse a version. If any released byte must change, prepare | ||
| a new version and a new signed tag. |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.