actions / starter-workflows

Accelerating new GitHub Actions workflows
https://github.com/features/actions
Other
8.59k stars 5.08k forks source link

Default to publishing with provenance in npm publish workflow #2347

Closed ericcornelissen closed 3 days ago

ericcornelissen commented 3 months ago

Pre-requisites


Please note that at this time we are only accepting new starter workflows for Code Scanning. Updates to existing starter workflows are fine.


Tasks

For all workflows, the workflow:

For CI workflows, the workflow:

Some general notes:


Description

Update the npm-publish.yml starter workflow to publish with provenance to encourage users publishing to npm to use provenance. The implementation is based on (but improved compared to) the example found at https://docs.npmjs.com/generating-provenance-statements (accessed March 20, 2024, copied below). A prerequisite for this is upgrading Node.js to v20 because it ships with an npm version that supports the --provenance flag.

I can see this being in violation with "Automation and CI workflows should not send data to any 3rd party service except for the purposes of installing dependencies." which is why I didn't mark it. If it is, feel free to reject this.

Part of the changes here are covered by #2269


workflow from npm docs ```yml name: Publish Package to npmjs on: release: types: [created] jobs: build: runs-on: ubuntu-latest permissions: contents: read id-token: write steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '18.x' registry-url: 'https://registry.npmjs.org' - run: npm install -g npm - run: npm ci - run: npm publish --provenance --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} ```
github-actions[bot] commented 1 week ago

This pull request has become stale and will be closed automatically within a period of time. Sorry about that.