ci: generate npm provenance statements when publishing #2308
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.
Which problem is this PR solving?
npm has a feature to display provenance statements for published packages. This allows users to see and verify how the package in npm has been built and published. Documentation for the npm feature is here.
Short description of the changes
Since this repository is already using a Github Actions workflow to publish to npm, the only change is to add the
id-token
permission and configure npm to publish with provenance. There are three options documented here:NPM_CONFIG_PROVENANCE
env variablepublishConfig.provenance
configuration in package.jsonI have chosen the environment variable. The package.json option would require updating all package.json files for packages that are published. The npmrc option seems less visible to me than having it directly in the workflow.
I have not tested this with this repository (due to the
release-please
process). However, I setup a separate repository for testing from which I was able to simulate publishing similar to how it works here. An example of a published package with the provenance statement can be seen here.