Skip to content

Commit db12c06

Browse files
committed
feat: refactor release workflow to use candidate branch
- Add release/candidate as temporary branch for release prep - Release-please auto-calculates version from conventional commits - Finalize workflow creates release/v{version} after PR merge - Rename workflows with consistent "Release:" prefix - Add skip-github-release to config (manual release creation) - Update publish workflow to check out from release branch
1 parent 5ea1228 commit db12c06

File tree

7 files changed

+121
-109
lines changed

7 files changed

+121
-109
lines changed

.github/release-please-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"release-type": "python",
66
"package-name": "google-adk-community",
77
"include-component-in-tag": false,
8-
"draft": true,
8+
"skip-github-release": true,
99
"changelog-path": "CHANGELOG.md",
1010
"changelog-sections": [
1111
{"type": "feat", "section": "Features"},

.github/workflows/cut-release-branch.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
name: Cherry-pick to Release
1+
# Cherry-picks a commit from main to the release/candidate branch.
2+
# Use this to include bug fixes in an in-progress release.
3+
name: "Release: Cherry-pick"
24

35
on:
46
workflow_dispatch:
57
inputs:
6-
version:
7-
description: 'Release version (e.g., 0.3.0)'
8-
required: true
9-
type: string
108
commit_sha:
119
description: 'Commit SHA to cherry-pick'
1210
required: true
@@ -22,7 +20,7 @@ jobs:
2220
steps:
2321
- uses: actions/checkout@v4
2422
with:
25-
ref: release/v${{ inputs.version }}
23+
ref: release/candidate
2624
fetch-depth: 0
2725

2826
- name: Configure git
@@ -32,19 +30,17 @@ jobs:
3230
3331
- name: Cherry-pick commit
3432
run: |
35-
echo "Cherry-picking ${{ inputs.commit_sha }} to release/v${{ inputs.version }}"
33+
echo "Cherry-picking ${{ inputs.commit_sha }} to release/candidate"
3634
git cherry-pick ${{ inputs.commit_sha }}
3735
3836
- name: Push changes
3937
run: |
40-
git push origin release/v${{ inputs.version }}
41-
echo "Successfully cherry-picked commit to release/v${{ inputs.version }}"
38+
git push origin release/candidate
39+
echo "Successfully cherry-picked commit to release/candidate"
4240
4341
- name: Trigger Release Please
4442
env:
4543
GH_TOKEN: ${{ github.token }}
4644
run: |
47-
gh workflow run release-please.yml \
48-
--repo ${{ github.repository }} \
49-
-f version=${{ inputs.version }}
50-
echo "Triggered Release Please workflow for version ${{ inputs.version }}"
45+
gh workflow run release-please.yml --repo ${{ github.repository }}
46+
echo "Triggered Release Please workflow"

.github/workflows/release-cut.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Starts the release process by creating a release/candidate branch.
2+
# Triggers release-please to generate a changelog PR.
3+
name: "Release: Cut"
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
commit_sha:
9+
description: 'Commit SHA to cut from (leave empty for latest main)'
10+
required: false
11+
type: string
12+
13+
permissions:
14+
contents: write
15+
actions: write
16+
17+
jobs:
18+
cut-release:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
ref: ${{ inputs.commit_sha || 'main' }}
24+
25+
- name: Check for existing release/candidate branch
26+
env:
27+
GH_TOKEN: ${{ github.token }}
28+
run: |
29+
if git ls-remote --exit-code --heads origin release/candidate &>/dev/null; then
30+
echo "Error: release/candidate branch already exists"
31+
echo "Please finalize or delete the existing release candidate before starting a new one"
32+
exit 1
33+
fi
34+
35+
- name: Create and push release/candidate branch
36+
run: |
37+
git checkout -b release/candidate
38+
git push origin release/candidate
39+
echo "Created branch: release/candidate"
40+
41+
- name: Trigger Release Please
42+
env:
43+
GH_TOKEN: ${{ github.token }}
44+
run: |
45+
gh workflow run release-please.yml --repo ${{ github.repository }}
46+
echo "Triggered Release Please workflow"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Triggers when release-please PR is merged to release/candidate.
2+
# Creates the final release/v{version} branch and deletes the candidate branch.
3+
name: "Release: Finalize"
4+
5+
on:
6+
pull_request:
7+
types: [closed]
8+
branches:
9+
- release/candidate
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
finalize:
16+
if: github.event.pull_request.merged == true
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check for release-please PR
20+
id: check
21+
env:
22+
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
23+
run: |
24+
if echo "$LABELS" | grep -q "autorelease: pending"; then
25+
echo "is_release_pr=true" >> $GITHUB_OUTPUT
26+
else
27+
echo "Not a release-please PR, skipping"
28+
echo "is_release_pr=false" >> $GITHUB_OUTPUT
29+
fi
30+
31+
- uses: actions/checkout@v4
32+
if: steps.check.outputs.is_release_pr == 'true'
33+
with:
34+
ref: release/candidate
35+
36+
- name: Extract version from manifest
37+
if: steps.check.outputs.is_release_pr == 'true'
38+
id: version
39+
run: |
40+
VERSION=$(jq -r '.["."]' .github/.release-please-manifest.json)
41+
echo "version=$VERSION" >> $GITHUB_OUTPUT
42+
echo "Extracted version: $VERSION"
43+
44+
- name: Create release branch
45+
if: steps.check.outputs.is_release_pr == 'true'
46+
run: |
47+
git checkout -b "release/v${{ steps.version.outputs.version }}"
48+
git push origin "release/v${{ steps.version.outputs.version }}"
49+
echo "Created branch: release/v${{ steps.version.outputs.version }}"
50+
51+
- name: Delete release/candidate branch
52+
if: steps.check.outputs.is_release_pr == 'true'
53+
run: |
54+
git push origin --delete release/candidate
55+
echo "Deleted branch: release/candidate"
Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
name: Release Please
1+
# Runs release-please to create/update a PR with version bump and changelog.
2+
# Triggered by pushes to release/candidate or manually.
3+
name: "Release: Please"
24

35
on:
46
push:
57
branches:
6-
- 'release/**'
8+
- release/candidate
79
workflow_dispatch:
8-
inputs:
9-
version:
10-
description: 'Release version (e.g., 0.3.0)'
11-
required: true
12-
type: string
1310

1411
permissions:
1512
contents: write
@@ -19,49 +16,13 @@ jobs:
1916
release-please:
2017
runs-on: ubuntu-latest
2118
steps:
22-
- name: Determine version and branch
23-
id: vars
24-
run: |
25-
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
26-
VERSION="${{ inputs.version }}"
27-
BRANCH="release/v${{ inputs.version }}"
28-
else
29-
VERSION="${GITHUB_REF_NAME#release/v}"
30-
BRANCH="${GITHUB_REF_NAME}"
31-
fi
32-
echo "version=$VERSION" >> $GITHUB_OUTPUT
33-
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
34-
echo "Version: $VERSION, Branch: $BRANCH"
35-
3619
- uses: actions/checkout@v4
3720
with:
38-
ref: ${{ steps.vars.outputs.branch }}
39-
40-
- name: Check if release already exists
41-
id: check
42-
env:
43-
GH_TOKEN: ${{ github.token }}
44-
run: |
45-
VERSION="${{ steps.vars.outputs.version }}"
46-
if gh release view "v$VERSION" --repo ${{ github.repository }} &>/dev/null; then
47-
echo "Release v$VERSION already exists, skipping"
48-
echo "skip=true" >> $GITHUB_OUTPUT
49-
else
50-
echo "skip=false" >> $GITHUB_OUTPUT
51-
fi
52-
53-
- name: Set release-as version
54-
if: steps.check.outputs.skip != 'true'
55-
run: |
56-
jq --arg version "${{ steps.vars.outputs.version }}" \
57-
'.packages["."]["release-as"] = $version' \
58-
.github/release-please-config.json > tmp.json && mv tmp.json .github/release-please-config.json
21+
ref: release/candidate
5922

6023
- uses: googleapis/release-please-action@v4
61-
if: steps.check.outputs.skip != 'true'
62-
id: release
6324
with:
6425
token: ${{ secrets.RELEASE_PAT }}
6526
config-file: .github/release-please-config.json
6627
manifest-file: .github/.release-please-manifest.json
67-
target-branch: ${{ steps.vars.outputs.branch }}
28+
target-branch: release/candidate
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
name: Publish to PyPI
1+
# Builds and publishes the package to PyPI from a release branch.
2+
# Creates a merge-back PR to sync release changes to main.
3+
name: "Release: Publish to PyPi"
24

35
on:
46
workflow_dispatch:
@@ -18,7 +20,7 @@ jobs:
1820
steps:
1921
- uses: actions/checkout@v4
2022
with:
21-
ref: v${{ inputs.version }}
23+
ref: release/v${{ inputs.version }}
2224

2325
- name: Install uv
2426
uses: astral-sh/setup-uv@v4

0 commit comments

Comments
 (0)