Publish #10
This file contains hidden or 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" | |
on: | |
workflow_dispatch: | |
inputs: | |
new_version: | |
description: ref. https://docs.npmjs.com/cli/commands/npm-version | |
required: true | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write # The OIDC ID token is used for authentication with JSR. | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
registry-url: 'https://registry.npmjs.org' | |
- name: Publish package | |
run: | | |
# Setup Git user | |
git config user.name "actions-user" | |
git config user.email "[email protected]" | |
# Set package version | |
npm version $NEW_VERSION | |
node -p 'JSON.stringify({ ...require("./jsr.json"), version: require("./package.json").version }, undefined, "\t")' > _jsr.json && mv _jsr.json jsr.json | |
git add jsr.json | |
git commit --amend --no-edit | |
# Install dependencies | |
npm ci | |
# Publish | |
npm publish --provenance --access public | |
npm exec --yes -- jsr publish | |
# Push version up commit | |
git push | |
env: | |
NEW_VERSION: ${{ inputs.new_version }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |