Skip to content

Commit 26a4362

Browse files
patrickerclaude
andcommitted
ci: add GitHub Actions CI + release workflow
CI: - Tests on Node 18, 20, 22 - Runs on push to main and PRs Release (triggered by v* tags): - Runs tests first - Publishes to npm with provenance - Creates GitHub Release with auto-generated notes Usage: git tag v0.1.0 && git push --tags Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 44da2e7 commit 26a4362

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test (Node ${{ matrix.node-version }})
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: [18, 20, 22]
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
23+
- name: Install
24+
run: npm ci
25+
26+
- name: Test
27+
run: npm test

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
permissions:
8+
contents: write
9+
id-token: write
10+
11+
jobs:
12+
test:
13+
name: Test
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
22+
- run: npm ci
23+
- run: npm test
24+
25+
publish-npm:
26+
name: Publish to npm
27+
needs: test
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 20
35+
registry-url: https://registry.npmjs.org
36+
37+
- run: npm ci
38+
- run: npm publish --provenance --access public
39+
env:
40+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
42+
github-release:
43+
name: GitHub Release
44+
needs: test
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 0
50+
51+
- name: Generate release notes
52+
id: notes
53+
run: |
54+
# Get the previous tag
55+
PREV_TAG=$(git tag --sort=-v:refname | head -2 | tail -1)
56+
if [ -z "$PREV_TAG" ]; then
57+
echo "body=Initial release" >> $GITHUB_OUTPUT
58+
else
59+
NOTES=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s" --no-merges)
60+
echo "body<<EOF" >> $GITHUB_OUTPUT
61+
echo "$NOTES" >> $GITHUB_OUTPUT
62+
echo "EOF" >> $GITHUB_OUTPUT
63+
fi
64+
65+
- uses: softprops/action-gh-release@v2
66+
with:
67+
body: ${{ steps.notes.outputs.body }}
68+
generate_release_notes: true

0 commit comments

Comments
 (0)