Skip to content

Publish to npm

Publish to npm #2

Workflow file for this run

name: Publish to npm
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.3.0)'
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Sync READMEs
run: npm run sync
- name: Build
run: npm run build
- name: Validate version format
run: |
if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
echo "Error: Invalid version format. Expected semver (e.g., 1.3.0 or 1.3.0-beta.1)"
exit 1
fi
- name: Set version and publish
run: |
VERSION="${{ inputs.version }}"
# Set version in client and plugin
npm version "$VERSION" --workspace=packages/client --no-git-tag-version --allow-same-version
npm version "$VERSION" --workspace=packages/plugin --no-git-tag-version --allow-same-version
# Commit version changes
git add .
git commit -m "v${VERSION}"
git tag "v${VERSION}"
# Publish client and plugin (OIDC handles auth, provenance generated automatically)
npm publish --workspace=packages/client --access public
npm publish --workspace=packages/plugin --access public
# Push changes and tag
git push
git push --tags