Skip to content

Commit

Permalink
Add provenance attestation when publishing to NPM (#48)
Browse files Browse the repository at this point in the history
### Changelog
None

### Description

This adds a provenance attestation to the published package so consumers can verify that the package was built on GitHub Actions:
- https://github.blog/2023-04-19-introducing-npm-package-provenance/
- https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions

The package will appear like this on npm:

<img src="https://github.blog/wp-content/uploads/2023/04/npm-package-provenance-3.png?w=488&resize=488%2C394" width="250">
  • Loading branch information
jtbandes authored Apr 8, 2024
1 parent bc46b60 commit 464dfe0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
name: push
runs-on: ubuntu-latest

permissions:
# https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
id-token: write

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
Expand All @@ -24,8 +28,15 @@ jobs:
- run: yarn run lint:ci
- run: yarn run test

- run: yarn pack
- name: Publish to NPM (dry run)
# `yarn publish` does not support --provenance
run: npm publish foxglove-rosmsg-*.tgz --provenance --access public --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Publish to NPM
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: yarn publish --access public
# `yarn publish` does not support --provenance
run: npm publish foxglove-rosmsg-*.tgz --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

0 comments on commit 464dfe0

Please sign in to comment.