-
-
Notifications
You must be signed in to change notification settings - Fork 0
ci: add publish.yml, wire release-please to dispatch it #21
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
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,67 @@ | ||
| name: Publish | ||
|
|
||
| # Publishes to npm using OIDC trusted publishing: npm verifies this workflow's | ||
| # short-lived, workflow-scoped identity, so there is no npm token to store, | ||
| # rotate, or leak. Provenance attestations are generated automatically. | ||
| # | ||
| # Prerequisite, done once on npmjs.com: package settings -> Trusted publishers | ||
| # -> GitHub Actions, with repository mark-brannan/wire-wright and workflow | ||
| # file `publish.yml`. Until that exists this workflow will fail | ||
| # authentication, which is the correct failure mode. | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| # Deliberately no `push: tags` trigger. release-please.yml tags through a | ||
| # GitHub App installation token (not the default GITHUB_TOKEN), so that | ||
| # push DOES fire workflows -- and a `push: tags` listener here would start | ||
| # a second, racing publish alongside the explicit `gh workflow run | ||
| # publish.yml --ref <tag>` dispatch release-please.yml already does. | ||
| # workflow_dispatch is also the only trigger npm's OIDC trusted publisher | ||
| # is configured for on npmjs.com (this file, this repo). So a tag alone, | ||
| # pushed by hand, does not publish; run `gh workflow run publish.yml --ref | ||
| # vX.Y.Z` instead. | ||
|
|
||
| permissions: | ||
| contents: read # release-please.yml creates the tag and the GitHub Release | ||
| id-token: write # required: this is what mints the OIDC token | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| # workflow_dispatch can target a branch, not just a tag. A branch named | ||
| # to match package.json's version (e.g. "v0.1.1") would pass the tag | ||
| # check below despite not being an actual release tag -- npm trusted | ||
| # publishing doesn't restrict which ref a workflow_dispatch can run on. | ||
| # Refusing anything but a real tag closes that. | ||
| if: github.ref_type == 'tag' | ||
| steps: | ||
| # Nothing here writes to the repository -- release-please.yml owns the | ||
| # tag and the Release -- and the checkout's token should not outlive | ||
| # the step. Same rationale as test.yml's checkout. | ||
| - uses: actions/checkout@v7 | ||
| with: { persist-credentials: false } | ||
|
mark-brannan marked this conversation as resolved.
|
||
|
|
||
| - uses: actions/setup-node@v7 | ||
| with: | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org | ||
|
|
||
| # Trusted publishing requires npm >= 11.5.1, newer than what ships with | ||
| # Node 22. | ||
| - run: npm install -g npm@latest | ||
|
mark-brannan marked this conversation as resolved.
|
||
|
|
||
| - name: Refuse to publish a tag that disagrees with package.json | ||
| run: | | ||
| TAG="${GITHUB_REF_NAME}" | ||
| PKG=$(node -p "require('./package.json').version") | ||
| if [ "${TAG#v}" != "$PKG" ]; then | ||
| echo "tag $TAG does not match package.json version $PKG" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # The one dependency is `ampacity`, same as test.yml. | ||
| - run: npm ci | ||
| - run: npm test | ||
|
|
||
| # No NODE_AUTH_TOKEN. Authentication is the OIDC identity above. | ||
| - run: npm publish | ||
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.