Skip to content

Commit 8d644b8

Browse files
committed
Release when tagged
1 parent dc64c60 commit 8d644b8

3 files changed

Lines changed: 92 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Requires NPM_TOKEN secret (https://www.npmjs.com/ → Access Tokens) with publish permission
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: "20"
23+
cache: "yarn"
24+
registry-url: "https://registry.npmjs.org"
25+
26+
- name: Install canvas dependencies
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev librsvg2-dev
30+
31+
- name: Install dependencies
32+
run: yarn install --frozen-lockfile
33+
34+
- name: Build
35+
run: yarn build
36+
37+
- name: Install Playwright browsers
38+
run: npx playwright install --with-deps chromium firefox
39+
40+
- name: Node tests
41+
run: yarn test
42+
43+
- name: Browser tests
44+
run: yarn test:browser
45+
46+
- name: Get version from tag
47+
id: version
48+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
49+
50+
- name: Update package.json version
51+
run: npm pkg set version="${{ steps.version.outputs.VERSION }}"
52+
53+
- name: Generate changelog
54+
run: |
55+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)
56+
if [ -z "$PREV_TAG" ]; then
57+
git log --pretty=format:"- %s (%h)" | head -100 > release-notes.md
58+
else
59+
git log $PREV_TAG..HEAD --pretty=format:"- %s (%h)" > release-notes.md
60+
fi
61+
if [ ! -s release-notes.md ]; then
62+
echo "No changes since previous release" > release-notes.md
63+
fi
64+
65+
- name: Publish to npm
66+
run: npm publish --access public --provenance --no-git-tag-version
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
69+
70+
- name: Create GitHub Release
71+
uses: softprops/action-gh-release@v2
72+
with:
73+
body_path: release-notes.md
74+
generate_release_notes: false
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,19 @@ The harness (`test/browser/browser-test.html`) loads Mocha, Chai, and Qured; `te
198198
199199
---
200200
201+
## Releasing
202+
203+
Push a version tag (e.g. `v1.0.0`) to trigger the release workflow:
204+
205+
```bash
206+
git tag v1.0.0
207+
git push origin v1.0.0
208+
```
209+
210+
The workflow will run tests, publish to npm, and create a GitHub release with a changelog of commit messages since the previous tag. Configure the `NPM_TOKEN` repository secret (npm → Access Tokens) with publish permission.
211+
212+
---
213+
201214
## License
202215
203216
MIT

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"node"
3636
],
3737
"license": "MIT",
38+
"publishConfig": {
39+
"access": "public"
40+
},
3841
"devDependencies": {
3942
"@playwright/test": "^1.49.0",
4043
"@types/node": "^20.10.0",

0 commit comments

Comments
 (0)