Publish to package registry #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to package registry | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
jsr: | |
type: boolean | |
default: true | |
npm: | |
type: boolean | |
default: true | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write # The OIDC ID token is used for authentication with JSR. | |
steps: | |
- name: Checkout repository | |
if: ${{ inputs.jsr || inputs.npm }} | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
if: ${{ inputs.jsr || inputs.npm }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
registry-url: 'https://registry.npmjs.org' | |
cache: npm | |
- name: Restore cache | |
if: ${{ inputs.jsr || inputs.npm }} | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.npm | |
key: ${{ runner.os }}-publish-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-publish- | |
- name: Install npm dependencies | |
if: ${{ inputs.jsr || inputs.npm }} | |
run: npm ci | |
- name: Publish to jsr | |
if: ${{ inputs.jsr }} | |
run: npx jsr publish | |
- name: Publish to npm | |
if: ${{ inputs.npm }} | |
run: npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |