From 12587aa8cce7214a14b565f7464e0a5d424aa46f Mon Sep 17 00:00:00 2001 From: shawn Date: Mon, 1 Jun 2026 16:14:53 +0800 Subject: [PATCH] ci: add release workflow to publish extension zip on tag --- .github/workflows/release.yml | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7d30e6c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + push: + tags: ["v*"] + workflow_dispatch: + +permissions: + contents: write + +jobs: + release: + name: Build and Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - uses: pnpm/action-setup@v6 + with: + version: 10 + + - uses: actions/setup-node@v6 + with: + node-version: 24 + cache: pnpm + + - run: pnpm install --frozen-lockfile + + - name: Verify tag matches version + if: startsWith(github.ref, 'refs/tags/v') + run: | + TAG_VERSION="${GITHUB_REF_NAME#v}" + PKG_VERSION=$(node -p "require('./package.json').version") + MANIFEST_VERSION=$(node -p "require('./static/manifest.json').version") + [ "$TAG_VERSION" = "$PKG_VERSION" ] || { echo "Tag $TAG_VERSION != package.json $PKG_VERSION"; exit 1; } + [ "$TAG_VERSION" = "$MANIFEST_VERSION" ] || { echo "Tag $TAG_VERSION != manifest.json $MANIFEST_VERSION"; exit 1; } + + - name: Build and package + run: pnpm run pack + + - name: Stage release asset + run: | + VERSION=$(node -p "require('./package.json').version") + mv better-github.zip "better-github-v${VERSION}.zip" + + - name: Create GitHub Release + if: startsWith(github.ref, 'refs/tags/v') + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + files: better-github-v*.zip