Skip to content

Commit 9f80a0d

Browse files
authored
chore: add a release github action (#7)
that publishes to npm when a new release tag is added to the repo (through prepare-release.js). Add a prepublishOnly entry in package.json scripts to run `npm run build` before publishing. Add process/RELEASE.md explaining the release process.
1 parent 0ec7624 commit 9f80a0d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

.github/workflows/publish.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: 12
15+
registry-url: https://registry.npmjs.org/
16+
- run: yarn install
17+
- run: npm publish --access public
18+
env:
19+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"scripts": {
1414
"build": "rimraf dist && rollup -c",
1515
"test": "npm run build && ava",
16-
"test:update-snapshots": "npm run build && ava --update-snapshots"
16+
"test:update-snapshots": "npm run build && ava --update-snapshots",
17+
"prepublishOnly": "npm run build"
1718
},
1819
"repository": {
1920
"type": "git",

process/RELEASE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# RELEASE PROCESS
2+
3+
## Publishing a new release
4+
5+
In the root directory run
6+
7+
```sh
8+
node prepare-release.js <NEW VERSION NUMBER>
9+
```
10+
11+
This will
12+
13+
- Validate that the new version is greater than the current one
14+
- Update package.json to the new version number
15+
- Update CHANGELOG.md by running `standard-changelog`
16+
- Prompt you to create a release commit and tag it with the version number
17+
- Prompt you to push the commit and tag to origin
18+
19+
This should in turn kick off the release Github Action at
20+
`.github/workflows/publish.yml`, which should publish the build to NPM.

0 commit comments

Comments
 (0)