Skip to content

Publish to npm

Publish to npm #4

Workflow file for this run

name: Publish to npm
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g. 1.6.0)'
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- run: npm install -g npm@latest
- run: npm ci
# Bump package.json to the requested version
- name: Set version
run: npm version "${{ inputs.version }}" --no-git-tag-version --allow-same-version
- run: npm run check
# Commit version bump, tag, and push
- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json
git commit -m "v${{ inputs.version }}"
git tag "v${{ inputs.version }}"
git push origin main --tags
# Create GitHub Release from the new tag
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "v${{ inputs.version }}" --generate-notes
- run: npm publish --provenance --access public