Skip to content

Commit a767ff5

Browse files
committed
build: add publish workflow
1 parent a29f7b4 commit a767ff5

5 files changed

Lines changed: 186 additions & 68 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
concurrency:
13+
group: publish
14+
cancel-in-progress: false
15+
16+
jobs:
17+
publish:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Extract version from tag
21+
id: version
22+
run: |
23+
VERSION="${GITHUB_REF#refs/tags/v}"
24+
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+)?$'; then
25+
echo "Error: tag must be vX.Y.Z format, got: $GITHUB_REF"
26+
exit 1
27+
fi
28+
echo "Releasing version: $VERSION"
29+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
30+
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Check version
35+
run: |
36+
VERSION="${{ steps.version.outputs.version }}"
37+
ACTUAL=$(grep -m1 '"version"' package.json | sed -E 's/.*"version": "([^"]*)".*/\1/')
38+
if [ "$ACTUAL" != "$VERSION" ]; then
39+
echo "Error: package.json has version $ACTUAL but tag is v$VERSION"
40+
exit 1
41+
fi
42+
echo "OK: package.json = $ACTUAL"
43+
44+
- name: Setup Node
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: 24
48+
registry-url: 'https://registry.npmjs.org'
49+
50+
- name: Install dependencies
51+
run: npm ci
52+
53+
- name: Build
54+
run: npm run build
55+
56+
- name: Publish to npm
57+
run: npm publish --provenance --no-git-checks

‎.node-version‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

0 commit comments

Comments
 (0)