From fad051f8779683ece4f5986ee6fd569f97c3d5fd Mon Sep 17 00:00:00 2001 From: DeaglePC Date: Thu, 11 Jun 2026 21:51:05 +0800 Subject: [PATCH] chore(release): build extension zip locally during npm run release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously `npm run release` only bumped the version and pushed the tag, leaving the actual zip to be built by CI — so there was no local artifact. Now the release script runs `npm run build:ext` before committing/tagging, and a failed build rolls back the version bump and aborts before anything is published. The zip is written to frontend/release/ (gitignored) instead of the frontend root, matching where release artifacts are kept; the CI artifact path is updated to match. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/build.yml | 2 +- frontend/scripts/release.mjs | 16 ++++++++++++++-- frontend/scripts/zip.mjs | 9 ++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d67dfe..bdf5ca0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: catheadtab-extension - path: frontend/catheadtab-*.zip + path: frontend/release/catheadtab-*.zip retention-days: 7 release: diff --git a/frontend/scripts/release.mjs b/frontend/scripts/release.mjs index abbd6f0..1cd12ad 100644 --- a/frontend/scripts/release.mjs +++ b/frontend/scripts/release.mjs @@ -53,11 +53,23 @@ if (!changelog.some((e) => e.version === version)) { console.warn(`\nāš ļø changelog.json has no entry for ${version}. Add one before releasing for proper release notes.`); } -// 5. Commit, tag, and push (pushing the tag triggers CI to build + release). +// 5. Build the extension zip locally (release/catheadtab-v.zip). +// Building before commit/tag means a broken build aborts the release before +// anything is published; roll back the bump so the tree is clean for a retry. +console.log(`\nšŸ“¦ Building extension zip for ${tag}...\n`); +try { + run('npm run build:ext'); +} catch { + run('git checkout -- package.json package-lock.json public/manifest.json'); + console.error('\nāŒ build:ext failed — version bump rolled back, nothing committed or pushed.'); + process.exit(1); +} + +// 6. Commit, tag, and push (pushing the tag triggers CI to build + release). console.log(`\nšŸš€ Releasing ${tag}\n`); run('git add package.json package-lock.json public/manifest.json'); run(`git commit -m "chore: release ${tag}"`); run(`git tag -a ${tag} -m "chore: release ${tag}"`); run('git push --follow-tags'); -console.log(`\nšŸŽ‰ Pushed ${tag}. CI will build the zip and create the GitHub Release.`); +console.log(`\nšŸŽ‰ Pushed ${tag}. Local zip: release/catheadtab-${tag.slice(1)}.zip — CI will build the same and create the GitHub Release.`); diff --git a/frontend/scripts/zip.mjs b/frontend/scripts/zip.mjs index 77eb1bd..8fba32c 100644 --- a/frontend/scripts/zip.mjs +++ b/frontend/scripts/zip.mjs @@ -60,9 +60,12 @@ if (fs.existsSync(distManifestPath)) { fs.writeFileSync(distManifestPath, JSON.stringify(distManifest, null, 2)); } -// Define output file +// Define output file — zips land in release/ (gitignored) so the repo root +// stays clean and local builds match where the user keeps release artifacts. +const releaseDir = path.join(frontendDir, 'release'); +fs.mkdirSync(releaseDir, { recursive: true }); const outputFileName = `catheadtab-v${version}.zip`; -const outputPath = path.join(frontendDir, outputFileName); +const outputPath = path.join(releaseDir, outputFileName); console.log(`Starting to create zip file: ${outputFileName}...`); @@ -74,7 +77,7 @@ const archive = archiver('zip', { // Listen for all archive data to be written output.on('close', function() { - console.log(`Successfully created ${outputFileName} (${archive.pointer()} bytes)`); + console.log(`Successfully created release/${outputFileName} (${archive.pointer()} bytes)`); console.log('Ready to upload to Chrome Web Store!'); });