From daf29d6a4ad3c7ae1b42c27ee08deb2f6c891a4e Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Thu, 23 Apr 2026 12:02:25 -0700 Subject: [PATCH] [Infra] Add standalone create-release-branch workflow Extracts release branch creation into a separate reusable workflow (create-release-branch.yml) that can be triggered independently via workflow_dispatch or called from other workflows via workflow_call. create-release.yml now dispatches it as a dependent job after the release publishes, keeping both workflows decoupled. --- .github/workflows/create-release-branch.yml | 65 +++++++++++++++++++++ .github/workflows/create-release.yml | 9 +++ 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/create-release-branch.yml diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml new file mode 100644 index 0000000000..13b76c94df --- /dev/null +++ b/.github/workflows/create-release-branch.yml @@ -0,0 +1,65 @@ +name: Create Release Branch + +on: + workflow_dispatch: + inputs: + tag: + description: "Release tag (e.g. v1.83.0-stable) — branch will be named release/" + required: true + type: string + commit_hash: + description: "Full 40-char commit SHA the branch should point to" + required: true + type: string + workflow_call: + inputs: + tag: + description: "Release tag" + required: true + type: string + commit_hash: + description: "Full 40-char commit SHA the branch should point to" + required: true + type: string + +permissions: {} + +jobs: + create-branch: + name: Create Release Branch + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Validate inputs + env: + TAG: ${{ inputs.tag }} + COMMIT_HASH: ${{ inputs.commit_hash }} + run: | + if ! echo "${COMMIT_HASH}" | grep -qE '^[0-9a-f]{40}$'; then + echo "::error::commit_hash must be a full 40-character commit SHA" + exit 1 + fi + if ! echo "${TAG}" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+'; then + echo "::error::tag must start with vX.Y.Z" + exit 1 + fi + + - name: Create release branch + env: + TAG: ${{ inputs.tag }} + COMMIT_HASH: ${{ inputs.commit_hash }} + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const tag = process.env.TAG; + const commitHash = process.env.COMMIT_HASH; + const branchName = `release/${tag}`; + + await github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: `refs/heads/${branchName}`, + sha: commitHash, + }); + core.info(`Created branch ${branchName} at ${commitHash}`); diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index b863397985..a5b3dd8113 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -102,6 +102,15 @@ jobs: body: updatedBody, draft: false, }); + } catch (error) { core.setFailed(error.message); } + + create-branch: + name: Create Release Branch + needs: release + uses: ./.github/workflows/create-release-branch.yml + with: + tag: ${{ inputs.tag }} + commit_hash: ${{ inputs.commit_hash }}