Skip to content

fix: add repository field for npm provenance #2

fix: add repository field for npm provenance

fix: add repository field for npm provenance #2

Workflow file for this run

name: Publish to npm
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test:run
- name: Build
run: npm run build
- name: Determine npm tag and release type
id: release-info
run: |
TAG=${GITHUB_REF#refs/tags/v}
if [[ "$TAG" == *"-"* ]]; then
NPM_TAG=$(echo "$TAG" | sed 's/.*-\([a-zA-Z]*\).*/\1/')
PRERELEASE=true
else
NPM_TAG="latest"
PRERELEASE=false
fi
echo "tag=$NPM_TAG" >> $GITHUB_OUTPUT
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
echo "version=$TAG" >> $GITHUB_OUTPUT
- name: Publish to npm
run: npm publish --tag ${{ steps.release-info.outputs.tag }} --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
prerelease: ${{ steps.release-info.outputs.prerelease == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}