Skip to content

publish

publish #21

Workflow file for this run

name: publish
on:
release:
types: [published]
workflow_dispatch:
inputs:
dry_run:
description: Run npm publish in dry-run mode
required: true
default: true
type: boolean
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: npm
- run: npm ci
- run: npm run typecheck
- id: package
run: |
echo "name=$(node -p 'require(\"./package.json\").name')" >> "$GITHUB_OUTPUT"
echo "version=$(node -p 'require(\"./package.json\").version')" >> "$GITHUB_OUTPUT"
- id: published
run: |
package="${{ steps.package.outputs.name }}@${{ steps.package.outputs.version }}"
if npm view "$package" version >/dev/null 2>&1; then
echo "Package $package is already published; skipping npm publish."
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- if: github.event_name == 'workflow_dispatch' && inputs.dry_run
run: npm pack --dry-run
- if: (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run)) && steps.published.outputs.exists != 'true'
run: npm publish