Skip to content

Commit ff0e35b

Browse files
authored
Merge pull request #81 from bats-core/release-workflow
release workflow
2 parents 912a988 + 9caa17b commit ff0e35b

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

.github/CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Contributing
2+
3+
## Releasing
4+
5+
From a clean working copy, run `npm version major|minor|patch|VERSION`.
6+
This will bump the package version, commit, tag, and push.
7+
The tag-push event triggers the release workflow on GitHub.
8+
The workflow creates a GitHub Release from the tag and publishes to npm.

.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 <[email protected]> (http://sstephenson.us/)",
10-
"Jason Karns <[email protected]> (http://jason.karns.name)",
10+
"Jason Karns <[email protected]> (http://jasonkarns.com)",
1111
"Mislav Marohnić <[email protected]> (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)