Skip to content

Commit d89e736

Browse files
committed
Add release workflow for npm and GH Releases
1 parent 912a988 commit d89e736

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
on:
3+
push: { tags: "v[0-9]+.[0-9]+.[0-9]+*" }
4+
5+
permissions: {}
6+
jobs:
7+
github:
8+
permissions: { contents: write }
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
12+
with: { egress-policy: audit }
13+
- uses: actions/checkout@v4
14+
# TODO exit this job differently than success if release already exists
15+
- name: gh release create
16+
run: |
17+
# shellcheck disable=SC2086
18+
gh release view $tag || \
19+
gh release create ${tag/*-*/"$tag" --prerelease} --generate-notes
20+
env:
21+
GH_TOKEN: ${{ github.token }}
22+
tag: ${{ github.ref_name }}
23+
24+
npm:
25+
permissions: { id-token: write }
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
29+
with: { egress-policy: audit }
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-node@v4
32+
with:
33+
registry-url: https://registry.npmjs.org
34+
- run: npm ci
35+
- run: npm publish --provenance
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"author": "Zoltán Tömböl (https://github.com/ztombol)",
88
"contributors": [
99
"Sam Stephenson <sstephenson@gmail.com> (http://sstephenson.us/)",
10-
"Jason Karns <jason.karns@gmail.com> (http://jason.karns.name)",
10+
"Jason Karns <jason.karns@gmail.com> (http://jasonkarns.com)",
1111
"Mislav Marohnić <mislav.marohnic@gmail.com> (http://mislav.net/)",
1212
"Tim Pope (https://github.com/tpope)"
1313
],
@@ -23,9 +23,7 @@
2323
],
2424
"scripts": {
2525
"test": "bats ${CI+-t} test",
26-
"postversion": "npm publish",
27-
"prepublishOnly": "npm run publish:github",
28-
"publish:github": "git push --follow-tags"
26+
"postversion": "git push --follow-tags"
2927
},
3028
"devDependencies": {
3129
"bats": "^1",

0 commit comments

Comments
 (0)