Skip to content

Publish to npm

Publish to npm #6

Workflow file for this run

name: Publish to npm
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.0, or "from-package" to use package.json version)'
required: false
default: 'from-package'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build
run: bun run build
- name: Update version (if specified)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'from-package'
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version --allow-same-version
- name: Update version from release tag
if: github.event_name == 'release'
run: npm version ${GITHUB_REF_NAME#v} --no-git-tag-version --allow-same-version
- name: Publish to npm
run: npm publish --access public --provenance