From e9689dec952828d186e7537ebb7d94e02e456b9c Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Thu, 13 Nov 2025 18:37:28 +0000 Subject: [PATCH 1/2] feat: add npm publish workflow with trusted publishing - 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 --- .github/workflows/publish.yml | 82 +++++++++++++++++++++++++++++++++++ package.json | 5 +-- 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..9a5ac787 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,82 @@ +name: publish + +on: + push: + tags: + - 'v*' + +jobs: + publish: + name: publish to npm + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # Required for OIDC trusted publishing + steps: + - name: Checkout tag + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + submodules: recursive + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Setup Zig + uses: ./.github/actions/setup-zig + with: + version: 0.15.2 + + - name: Validate tag matches package.json version + run: | + # Extract version from package.json + PKG_VERSION=$(jq -r .version package.json) + + # Extract version from git tag (strip 'v' prefix) + TAG_VERSION=${GITHUB_REF#refs/tags/v} + + echo "Package version: $PKG_VERSION" + echo "Tag version: $TAG_VERSION" + + if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then + echo "❌ Error: Version mismatch!" + echo " package.json version: $PKG_VERSION" + echo " Git tag version: $TAG_VERSION" + echo "" + echo "Please ensure the git tag matches the version in package.json" + exit 1 + fi + + echo "✅ Version validation passed: $PKG_VERSION" + + - name: Build WASM + run: ./scripts/build-wasm.sh + + - name: Install dependencies + run: bun install + + - name: Check formatting + run: bun run fmt + + - name: Run linter + run: bun run lint + + - name: Check types + run: bun run typecheck + + - name: Run tests + run: bun test + + - name: Build library + run: bun run build + + - name: Setup Node.js with npm 11+ (for trusted publishing) + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + + - name: Publish to npm (with OIDC trusted publishing) + run: npm publish --provenance --access public diff --git a/package.json b/package.json index 03b66d46..154402e9 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@coder/ghostty-web", + "name": "ghostty-web", "version": "0.1.0", "description": "Web-based terminal emulator using Ghostty's VT100 parser via WebAssembly", "type": "module", @@ -34,8 +34,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/coder/ghostty-web.git", - "directory": "packaging" + "url": "https://github.com/coder/ghostty-web.git" }, "bugs": "https://github.com/coder/ghostty-web/issues", "homepage": "https://github.com/coder/ghostty-web#readme", From 2208b2a8ec1d389b439b53dce3daa3a066c86378 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Thu, 13 Nov 2025 18:54:02 +0000 Subject: [PATCH 2/2] chore: run prettier --- .github/workflows/publish.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9a5ac787..6292e04c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,13 +33,13 @@ jobs: run: | # Extract version from package.json PKG_VERSION=$(jq -r .version package.json) - + # Extract version from git tag (strip 'v' prefix) TAG_VERSION=${GITHUB_REF#refs/tags/v} - + echo "Package version: $PKG_VERSION" echo "Tag version: $TAG_VERSION" - + if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then echo "❌ Error: Version mismatch!" echo " package.json version: $PKG_VERSION" @@ -48,7 +48,7 @@ jobs: echo "Please ensure the git tag matches the version in package.json" exit 1 fi - + echo "✅ Version validation passed: $PKG_VERSION" - name: Build WASM