Publish to npm #4
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 to npm | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Tag to release (e.g. v0.0.1)" | |
required: true | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write # Required for provenance | |
steps: | |
- name: Checkout | |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
with: | |
fetch-depth: 0 | |
- name: Checkout release tag | |
run: | | |
git fetch --tags | |
TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}" | |
if [ -z "$TAG" ]; then | |
echo "Error: No tag provided in release event or workflow_dispatch input" | |
exit 1 | |
fi | |
echo "Checking out tag $TAG" | |
git checkout "$TAG" | |
- name: Setup Node.js | |
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
with: | |
node-version: '22' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build package | |
run: npm run build | |
- name: Publish to npm | |
run: npm publish --provenance --access public |