Skip to content

Publish to npm (OIDC) #4

Publish to npm (OIDC)

Publish to npm (OIDC) #4

Workflow file for this run

name: Publish to npm (OIDC)
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 3.7.1). Leave blank to use package.json.'
required: false
type: string
permissions:
id-token: write
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Upgrade npm (OIDC trusted publisher requires npm 11.5.1+)
run: |
npm install -g npm@latest
npm --version
- name: Configure npm registry (no auth — OIDC will handle it)
run: npm config set registry https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm test
- name: Update version (if specified)
if: ${{ github.event.inputs.version }}
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version
- name: Publish to npm (OIDC)
run: npm publish --provenance --access public