Skip to content

Manual Publish to npm and JSR #22

Manual Publish to npm and JSR

Manual Publish to npm and JSR #22

Workflow file for this run

name: Manual Publish to npm and JSR
on:
workflow_dispatch:
jobs:
publish-npm:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24.x"
registry-url: "https://registry.npmjs.org"
- name: Install, Check, Build, and Test
run: |
npm ci
npm run check:all
- name: Publish to npm
run: |
VERSION=$(node -p "require('./package.json').version")
# If version includes 'dev', publish with 'dev' tag, otherwise use 'latest'
if echo "$VERSION" | grep -q 'dev'; then
TAG=dev
else
TAG=latest
fi
npm publish --provenance --access public --tag "$TAG"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create and Push Git Tag
run: |
VERSION=$(node -p "require('./package.json').version")
git tag "v$VERSION"
git push origin "v$VERSION"
- name: Create GitHub Release
run: |
VERSION=$(node -p "require('./package.json').version")
if echo "$VERSION" | grep -q 'dev'; then
gh release create "v$VERSION" --title "v$VERSION" --generate-notes --prerelease
else
gh release create "v$VERSION" --title "v$VERSION" --generate-notes
fi
env:
GH_TOKEN: ${{ github.token }}
publish-jsr:
runs-on: ubuntu-latest
needs: publish-npm
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24.x"
- name: Install dependencies
run: npm ci
- name: Publish to JSR
run: npx jsr publish