Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Add provenance attestation when publishing to NPM (#15)
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 23, 2024
1 parent f95d67b commit e9c6d16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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@v3
- uses: actions/setup-node@v3
Expand All @@ -23,8 +27,15 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn run lint:ci

- run: yarn pack
- name: Publish to NPM (dry run)
# `yarn publish` does not support --provenance
run: npm publish foxglove-rosmsg-msgs-common-*.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-msgs-common-*.tgz --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- jsonc -*-
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
Expand Down

0 comments on commit e9c6d16

Please sign in to comment.