name: Publish to NPM
on:
workflow_run:
workflows: ["Release Test"]
types:
- completed
jobs:
publish:
runs-on: ubuntu-latest
# Only run if the test workflow succeeded
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: read
id-token: write # Required for npm provenance
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Publish to NPM
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload npm logs
if: always()
uses: actions/upload-artifact@v4
with:
name: npm-logs
path: |
/home/runner/.npm/_logs/*.log
retention-days: 7