release: v1.1.3 #3
Workflow file for this run
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
| name: Publish | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| concurrency: | |
| group: publish-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - name: Upgrade npm for trusted publishing | |
| run: npm install -g npm@latest | |
| - name: Verify tag matches package.json | |
| run: | | |
| tag="${GITHUB_REF#refs/tags/v}" | |
| pkg=$(node -p "require('./package.json').version") | |
| if [ "$tag" != "$pkg" ]; then | |
| echo "ERROR: tag v$tag does not match package.json $pkg" | |
| exit 1 | |
| fi | |
| - name: Install | |
| run: npm ci | |
| - name: Test | |
| run: npm test | |
| - name: Generate SBOM | |
| run: npm sbom --sbom-format cyclonedx > sbom.cdx.json | |
| - name: Publish | |
| run: npm publish --provenance --access public | |
| - name: Attach SBOM to release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| tag="${GITHUB_REF#refs/tags/}" | |
| gh release upload "$tag" sbom.cdx.json --clobber \ | |
| || gh release create "$tag" sbom.cdx.json --title "$tag" --notes "Automated release for $tag" |