Skip to content

Commit e3f4cd4

Browse files
committed
add publish GitHub Action
1 parent 76183c6 commit e3f4cd4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/publish.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
new_version:
7+
description: ref. https://docs.npmjs.com/cli/commands/npm-version
8+
required: true
9+
type: choice
10+
options:
11+
- major
12+
- minor
13+
- patch
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
id-token: write # The OIDC ID token is used for authentication with JSR.
21+
steps:
22+
- name: Publish package
23+
uses: actions/[email protected]
24+
with:
25+
registry-url: 'https://registry.npmjs.org'
26+
run: |
27+
# Setup Git user
28+
git config user.name "actions-user"
29+
git config user.email "[email protected]"
30+
31+
# Set package version
32+
npm version $NEW_VERSION
33+
node -p 'JSON.stringify({ ...require("./jsr.json"), version: require("./package.json").version }, undefined, "\t")' > _jsr.json && mv _jsr.json jsr.json
34+
35+
# Publish
36+
npm publish --provenance --access public
37+
npx jsr publish --provenance
38+
39+
# Push version up commit
40+
git push
41+
env:
42+
NEW_VERSION: ${{ inputs.new_version }}
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)