Skip to content

Publish to NPM

Publish to NPM #19

Workflow file for this run

name: Publish to NPM
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
publish:
name: Build & Publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
package-manager-cache: false
- name: Install dependencies
run: npm ci
- name: Type check
run: npm run typecheck
- name: Build
run: npm run build
- name: Ensure version is not already published
run: |
PKG_NAME=$(node -p "require('./package.json').name")
PKG_VERSION=$(node -p "require('./package.json').version")
if npm view "${PKG_NAME}@${PKG_VERSION}" version >/dev/null 2>&1; then
echo "::error::${PKG_NAME}@${PKG_VERSION} is already published. Bump version before publishing."
exit 1
fi
- name: Publish to NPM
run: npm publish --access public