Skip to content

Commit cd07ca9

Browse files
author
Aleksey Arakelyan
committed
added workflow for publishing
1 parent d401b01 commit cd07ca9

2 files changed

Lines changed: 91 additions & 90 deletions

File tree

‎.github/workflows/publish-npm.yml‎

Lines changed: 0 additions & 90 deletions
This file was deleted.

‎.github/workflows/release.yml‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v6
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v6
18+
with:
19+
node-version: 22
20+
registry-url: https://registry.npmjs.org/
21+
cache: npm
22+
23+
- name: Upgrade npm to a trusted-publishing-capable version
24+
run: npm install -g npm@latest
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Typecheck
30+
run: npm run typecheck
31+
32+
- name: Build
33+
run: npm run build
34+
35+
- name: Verify tag matches package version
36+
run: |
37+
set -euo pipefail
38+
tag="${GITHUB_REF_NAME#v}"
39+
pkg=$(node -p "require('./package.json').version")
40+
echo "tag=$tag pkg=$pkg"
41+
if [ "$tag" != "$pkg" ]; then
42+
echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $pkg"
43+
exit 1
44+
fi
45+
46+
- name: Pack tarball
47+
run: npm pack
48+
49+
- uses: actions/upload-artifact@v4
50+
with:
51+
name: dist
52+
path: "*.tgz"
53+
54+
publish-npm:
55+
needs: build
56+
runs-on: ubuntu-latest
57+
permissions:
58+
id-token: write
59+
steps:
60+
- uses: actions/download-artifact@v4
61+
with:
62+
name: dist
63+
64+
- name: Setup Node.js
65+
uses: actions/setup-node@v6
66+
with:
67+
node-version: 22
68+
registry-url: https://registry.npmjs.org/
69+
70+
- name: Upgrade npm to a trusted-publishing-capable version
71+
run: npm install -g npm@latest
72+
73+
- name: Publish (via npm trusted publisher / OIDC)
74+
run: npm publish *.tgz
75+
76+
github-release:
77+
needs: publish-npm
78+
runs-on: ubuntu-latest
79+
permissions:
80+
contents: write
81+
steps:
82+
- uses: actions/download-artifact@v4
83+
with:
84+
name: dist
85+
86+
- name: Create GitHub Release
87+
uses: softprops/action-gh-release@v2
88+
with:
89+
tag_name: ${{ github.ref_name }}
90+
generate_release_notes: true
91+
files: "*.tgz"

0 commit comments

Comments
 (0)