From e98953c09bb5540a0d4ffbc70dbbf28cf7e15fa2 Mon Sep 17 00:00:00 2001 From: Vida Xie Date: Sat, 22 Aug 2026 22:43:09 +0800 Subject: [PATCH] ci: drive releases through pull requests --- .github/workflows/publish.yml | 30 +++++++++++++++++++++--------- package.json | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index af8d6aa..49557c1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,30 +1,42 @@ name: Publish Extensions on: - push: - tags: - - v* - workflow_dispatch: + pull_request: + types: [closed] + branches: [main] jobs: publish-extension: + if: >- + github.event.pull_request.merged == true && + github.event.pull_request.head.repo.full_name == github.repository && + startsWith(github.event.pull_request.head.ref, 'release/') + + runs-on: ubuntu-latest permissions: id-token: write contents: write actions: write - - runs-on: ubuntu-slim steps: - name: Setup JS uses: sxzz/workflows/setup-js@dd67f194be6388e12ee61ad0cd3b81cf74bfd294 with: fetch-all: true + - name: Create tag + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION=$(jq -r '.version' package.json) + gh api "repos/$GITHUB_REPOSITORY/git/refs" \ + -f ref="refs/tags/v$VERSION" \ + -f sha="${{ github.event.pull_request.merge_commit_sha }}" + - name: Generate Github Changelog run: npx changelogithub continue-on-error: true env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build run: pnpm build @@ -41,8 +53,8 @@ jobs: run: npx vsxpub --no-dependencies env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VSCE_PAT: ${{secrets.VSCE_PAT}} - OVSX_PAT: ${{secrets.OVSX_PAT}} + VSCE_PAT: ${{ secrets.VSCE_PAT }} + OVSX_PAT: ${{ secrets.OVSX_PAT }} # - name: Publish Zed Extension # uses: huacnlee/zed-extension-action@v2 diff --git a/package.json b/package.json index 9748e57..df41569 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "fmt:rust": "cargo fmt --manifest-path extensions/zed/Cargo.toml", "fmt:rust:check": "cargo fmt --manifest-path extensions/zed/Cargo.toml --check", "typecheck": "tsc -b --noEmit", - "release": "npx bumpp -r -a -x \"node scripts/sync-zed-version.ts\"", + "release": "npx bumpp --pr -r -a -x \"node scripts/sync-zed-version.ts\"", "prepare": "husky" }, "nano-staged": {