Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
ci: add trusted npm publishing
Tw93b97e80241bcf
diff --git a/.agents/skills/release/SKILL.md b/.agents/skills/release/SKILL.mdindex b184b3ad..19833a63 100644--- a/.agents/skills/release/SKILL.md+++ b/.agents/skills/release/SKILL.md@@ -16,10 +16,11 @@ Use this skill when preparing or executing a Pake release.## Version Files-Three files must be updated in sync — never update one without the others:+Four files must be updated in sync — never update one without the others:- `package.json` → `"version"`- `src-tauri/Cargo.toml` → `version` under `[package]`+- `src-tauri/Cargo.lock` → `version` for package `pake`- `src-tauri/tauri.conf.json` → `"version"`## Release Checklist@@ -27,12 +28,13 @@ Three files must be updated in sync — never update one without the others:### Pre-Release1. [ ] Confirm the new version number (check current: `cat package.json | jq .version`)-2. [ ] Update all three version files above+2. [ ] Update all four version files above3. [ ] Run `pnpm run format` — must pass cleanly4. [ ] Run `pnpm test` — must pass cleanly. If the release workflow step fails with `pnpm install ... exit code 1` against the CN mirror, re-run once; a single transient flake is acceptable, two consecutive failures is not.5. [ ] Run `pnpm run cli:build` — Rollup + TS must pass (catches type errors that `format` misses).-6. [ ] No uncommitted changes: `git status`-7. [ ] Commit version bump with message: `chore: bump version to VX.X.X`+6. [ ] Run `pnpm run release:check` — verifies version sync, package contents, and npm dry-run+7. [ ] No uncommitted changes: `git status`+8. [ ] Commit version bump with message: `chore: bump version to VX.X.X`### Tagging (triggers CI)@@ -48,7 +50,10 @@ Tag format: uppercase `V` prefix (e.g. `V3.11.0`), not `v3.11.0`.1. [ ] Confirm CI triggered: `gh run list --workflow=release.yml`2. [ ] Watch CI status: `gh run watch`3. [ ] Verify GitHub Release was created: `gh release view VX.X.X`-4. [ ] Publish to npm (manual): `npm publish`+4. [ ] Confirm npm Trusted Publishing triggered: `gh run list --workflow=npm-publish.yml`+5. [ ] Verify npm published the package: `npm view pake-cli version`++npm publishes through Trusted Publishing from `.github/workflows/npm-publish.yml`. Configure npm package settings with GitHub Actions, `tw93/Pake`, workflow file `npm-publish.yml`, and no environment. Local `npm publish` is only a fallback if CI or registry state blocks the trusted path.## Build Commands (local only)@@ -66,4 +71,4 @@ Cross-platform builds (Windows/Linux) are handled by CI, not locally.1. **NEVER** auto-commit or auto-push without explicit user request2. **NEVER** tag before all checks pass-3. **ALWAYS** verify the three version files are in sync before tagging+3. **ALWAYS** verify the four version files are in sync before taggingdiff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.ymlnew file mode 100644index 00000000..65c4360a--- /dev/null+++ b/.github/workflows/npm-publish.yml@@ -0,0 +1,71 @@+name: Publish npm Package++on:+ push:+ tags:+ - "V*"++permissions:+ contents: read+ id-token: write++concurrency:+ group: npm-publish-${{ github.ref }}+ cancel-in-progress: false++jobs:+ publish:+ name: Publish pake-cli+ runs-on: ubuntu-latest+ steps:+ - name: Checkout repository+ uses: actions/checkout@v6++ - name: Install pnpm+ uses: pnpm/action-setup@v4+ with:+ version: "10.26.2"+ run_install: false++ - name: Setup Node.js+ uses: actions/setup-node@v6+ with:+ node-version: "24"+ registry-url: "https://registry.npmjs.org"+ package-manager-cache: false++ - name: Install dependencies+ run: pnpm install --frozen-lockfile++ - name: Check release version+ run: node scripts/check-release-version.mjs "$GITHUB_REF_NAME"++ - name: Check formatting+ run: pnpm run format:check++ - name: Run unit tests+ run: npx vitest run++ - name: Build CLI+ run: pnpm run cli:build++ - name: Check package contents+ run: npm pack --dry-run --ignore-scripts++ - name: Publish to npm+ run: npm publish++ - name: Verify published version+ run: |+ VERSION="$(node -p "require('./package.json').version")"+ for attempt in {1..12}; do+ PUBLISHED="$(npm view "pake-cli@${VERSION}" version --registry=https://registry.npmjs.org 2>/dev/null || true)"+ if [ "$PUBLISHED" = "$VERSION" ]; then+ echo "Published pake-cli@${VERSION}"+ exit 0+ fi+ echo "Waiting for npm registry to expose pake-cli@${VERSION} (attempt ${attempt}/12)"+ sleep 10+ done+ echo "pake-cli@${VERSION} was not visible in npm registry after publish"+ exit 1diff --git a/dist/cli.js b/dist/cli.jsindex 60c17c0e..2ba46506 100644--- a/dist/cli.js+++ b/dist/cli.js@@ -31,7 +31,7 @@ var bin = {};var repository = {type: "git",- url: "git+https://github.com/tw93/pake.git"+ url: "git+https://github.com/tw93/Pake.git"};var author = {name: "Tw93",@@ -62,6 +62,7 @@ var scripts = {test: "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",format: "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose","format:check": "prettier --check . --ignore-unknown",+ "release:check": "node scripts/check-release-version.mjs && pnpm run format:check && npx vitest run && pnpm run cli:build && npm pack --dry-run --ignore-scripts",update: "pnpm update --verbose && cd src-tauri && cargo update",prepublishOnly: "pnpm run cli:build"};diff --git a/package.json b/package.jsonindex 26d37e7e..19ca8434 100644--- a/package.json+++ b/package.json@@ -11,7 +11,7 @@},"repository": {"type": "git",- "url": "git+https://github.com/tw93/pake.git"+ "url": "git+https://github.com/tw93/Pake.git"},"author": {"name": "Tw93",@@ -42,6 +42,7 @@"test": "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js","format": "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose","format:check": "prettier --check . --ignore-unknown",+ "release:check": "node scripts/check-release-version.mjs && pnpm run format:check && npx vitest run && pnpm run cli:build && npm pack --dry-run --ignore-scripts","update": "pnpm update --verbose && cd src-tauri && cargo update","prepublishOnly": "pnpm run cli:build"},diff --git a/scripts/check-release-version.mjs b/scripts/check-release-version.mjsnew file mode 100644index 00000000..4679af12--- /dev/null+++ b/scripts/check-release-version.mjs@@ -0,0 +1,92 @@+#!/usr/bin/env node++import fs from "node:fs";+import path from "node:path";++const root = process.cwd();+const tag = process.argv[2] || process.env.GITHUB_REF_NAME;+const errors = [];++function readText(filePath) {+ return fs.readFileSync(path.join(root, filePath), "utf8");+}++function readJson(filePath) {+ return JSON.parse(readText(filePath));+}++function expectEqual(label, actual, expected) {+ if (actual !== expected) {+ errors.push(`${label}: expected ${expected}, got ${actual || "<missing>"}`);+ }+}++function extractCargoVersion() {+ const cargoToml = readText("src-tauri/Cargo.toml");+ const match = cargoToml.match(/^version\s*=\s*"([^"]+)"/m);+ return match?.[1];+}++function extractCargoLockVersion() {+ const cargoLock = readText("src-tauri/Cargo.lock");+ const match = cargoLock.match(+ /\[\[package\]\]\s+name = "pake"\s+version = "([^"]+)"/,+ );+ return match?.[1];+}++function extractDistVersion() {+ const distCli = readText("dist/cli.js");+ const match = distCli.match(+ /\b(?:var|let|const)\s+version\s*=\s*["']([^"']+)["'];/,+ );+ return match?.[1];+}++const packageJson = readJson("package.json");+const packageVersion = packageJson.version;+const expectedTag = tag || `V${packageVersion}`;++if (!/^V\d+\.\d+\.\d+$/.test(expectedTag)) {+ errors.push(+ `release tag must match Vx.y.z, got ${expectedTag || "<missing>"}`,+ );+} else {+ expectEqual("tag version", expectedTag.slice(1), packageVersion);+}++expectEqual(+ "src-tauri/Cargo.toml version",+ extractCargoVersion(),+ packageVersion,+);+expectEqual(+ "src-tauri/Cargo.lock version",+ extractCargoLockVersion(),+ packageVersion,+);+expectEqual(+ "src-tauri/tauri.conf.json version",+ readJson("src-tauri/tauri.conf.json").version,+ packageVersion,+);+expectEqual(+ "dist/cli.js bundled version",+ extractDistVersion(),+ packageVersion,+);+expectEqual(+ "package.json repository.url",+ packageJson.repository?.url,+ "git+https://github.com/tw93/Pake.git",+);++if (errors.length > 0) {+ console.error("Release version check failed:");+ for (const error of errors) {+ console.error(`- ${error}`);+ }+ process.exit(1);+}++console.log(`Release version check passed for V${packageVersion}`);