Skip to content

Commit c9f1505

Browse files
authored
feat: add npm publish workflow with trusted publishing (#24)
- Add automated publish workflow triggered by git tags (v*) - Use OIDC trusted publishing (no NPM_TOKEN needed) - Add tag validation to prevent version mismatches - Update package name to 'ghostty-web' (unscoped) - Remove incorrect repository.directory field - Generate provenance attestation for all published packages
1 parent 4143aeb commit c9f1505

2 files changed

Lines changed: 84 additions & 3 deletions

File tree

.github/workflows/publish.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
name: publish to npm
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write # Required for OIDC trusted publishing
15+
steps:
16+
- name: Checkout tag
17+
uses: actions/checkout@v4
18+
with:
19+
ref: ${{ github.ref }}
20+
submodules: recursive
21+
22+
- name: Setup Bun
23+
uses: oven-sh/setup-bun@v1
24+
with:
25+
bun-version: latest
26+
27+
- name: Setup Zig
28+
uses: ./.github/actions/setup-zig
29+
with:
30+
version: 0.15.2
31+
32+
- name: Validate tag matches package.json version
33+
run: |
34+
# Extract version from package.json
35+
PKG_VERSION=$(jq -r .version package.json)
36+
37+
# Extract version from git tag (strip 'v' prefix)
38+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
39+
40+
echo "Package version: $PKG_VERSION"
41+
echo "Tag version: $TAG_VERSION"
42+
43+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
44+
echo "❌ Error: Version mismatch!"
45+
echo " package.json version: $PKG_VERSION"
46+
echo " Git tag version: $TAG_VERSION"
47+
echo ""
48+
echo "Please ensure the git tag matches the version in package.json"
49+
exit 1
50+
fi
51+
52+
echo "✅ Version validation passed: $PKG_VERSION"
53+
54+
- name: Build WASM
55+
run: ./scripts/build-wasm.sh
56+
57+
- name: Install dependencies
58+
run: bun install
59+
60+
- name: Check formatting
61+
run: bun run fmt
62+
63+
- name: Run linter
64+
run: bun run lint
65+
66+
- name: Check types
67+
run: bun run typecheck
68+
69+
- name: Run tests
70+
run: bun test
71+
72+
- name: Build library
73+
run: bun run build
74+
75+
- name: Setup Node.js with npm 11+ (for trusted publishing)
76+
uses: actions/setup-node@v4
77+
with:
78+
node-version: '20'
79+
registry-url: 'https://registry.npmjs.org'
80+
81+
- name: Publish to npm (with OIDC trusted publishing)
82+
run: npm publish --provenance --access public

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@coder/ghostty-web",
2+
"name": "ghostty-web",
33
"version": "0.1.0",
44
"description": "Web-based terminal emulator using Ghostty's VT100 parser via WebAssembly",
55
"type": "module",
@@ -34,8 +34,7 @@
3434
],
3535
"repository": {
3636
"type": "git",
37-
"url": "https://github.com/coder/ghostty-web.git",
38-
"directory": "packaging"
37+
"url": "https://github.com/coder/ghostty-web.git"
3938
},
4039
"bugs": "https://github.com/coder/ghostty-web/issues",
4140
"homepage": "https://github.com/coder/ghostty-web#readme",

0 commit comments

Comments
 (0)