Skip to content

Commit 2e40acd

Browse files
committed
ci: add release-please automation with versioned branch workflow
- Add release-please config with draft releases and changelog sections - Add cut-release-branch workflow: creates branch, bumps version, builds wheel - Add release-please workflow: creates CHANGELOG PR, uses version from branch name - Add publish-pypi workflow: publishes to PyPI when draft release is published Release flow: 1. Run "Cut Release Branch" with version → builds wheel for testing 2. Release-please creates CHANGELOG PR for review 3. Merge PR → draft release created 4. Publish draft → PyPI publish triggered
1 parent cc56a5e commit 2e40acd

5 files changed

Lines changed: 166 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.2.0"
3+
}

.github/release-please-config.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "python",
6+
"package-name": "google-adk-community",
7+
"draft": true,
8+
"changelog-path": "CHANGELOG.md",
9+
"skip-github-release": false,
10+
"changelog-sections": [
11+
{"type": "feat", "section": "Features"},
12+
{"type": "fix", "section": "Bug Fixes"},
13+
{"type": "perf", "section": "Performance Improvements"},
14+
{"type": "refactor", "section": "Code Refactoring"},
15+
{"type": "docs", "section": "Documentation"},
16+
{"type": "test", "section": "Tests", "hidden": true},
17+
{"type": "build", "section": "Build System", "hidden": true},
18+
{"type": "ci", "section": "CI/CD", "hidden": true},
19+
{"type": "style", "section": "Styles", "hidden": true},
20+
{"type": "chore", "section": "Miscellaneous Chores", "hidden": true}
21+
]
22+
}
23+
}
24+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Cut Release Branch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version for the release (e.g., 0.3.0)'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
cut-branch:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: main
21+
fetch-depth: 0
22+
23+
- name: Validate version format
24+
run: |
25+
if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
26+
echo "Error: Version must be in format X.Y.Z (e.g., 0.3.0)"
27+
exit 1
28+
fi
29+
30+
- name: Create release branch
31+
run: |
32+
BRANCH_NAME="release/v${{ inputs.version }}"
33+
git checkout -b "$BRANCH_NAME"
34+
echo "Created branch: $BRANCH_NAME"
35+
36+
- name: Bump version
37+
run: |
38+
# Update version.py
39+
sed -i 's/__version__ = ".*"/__version__ = "${{ inputs.version }}"/' src/google/adk_community/version.py
40+
41+
# Update release-please manifest
42+
echo '{".": "${{ inputs.version }}"}' > .github/.release-please-manifest.json
43+
44+
echo "Bumped version to ${{ inputs.version }}"
45+
46+
- name: Commit version bump
47+
run: |
48+
git config user.name "github-actions[bot]"
49+
git config user.email "github-actions[bot]@users.noreply.github.com"
50+
git add src/google/adk_community/version.py .github/.release-please-manifest.json
51+
git commit -m "chore: bump version to ${{ inputs.version }}"
52+
git push origin "release/v${{ inputs.version }}"
53+
54+
- name: Install uv
55+
uses: astral-sh/setup-uv@v4
56+
with:
57+
version: "latest"
58+
59+
- name: Set up Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: "3.11"
63+
64+
- name: Build wheel
65+
run: uv build
66+
67+
- name: Upload wheel for testing
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: dist-${{ inputs.version }}
71+
path: dist/
72+
retention-days: 30

.github/workflows/publish-pypi.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.release.tag_name }}
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v4
20+
with:
21+
version: "latest"
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.11"
27+
28+
- name: Build package
29+
run: uv build
30+
31+
- name: Publish to PyPI
32+
env:
33+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
34+
run: uv publish
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- 'release/**'
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
release_created: ${{ steps.release.outputs.release_created }}
17+
tag_name: ${{ steps.release.outputs.tag_name }}
18+
steps:
19+
- name: Extract version from branch name
20+
id: extract-version
21+
run: |
22+
# Branch name is like "release/v0.3.0", extract "0.3.0"
23+
VERSION="${GITHUB_REF_NAME#release/v}"
24+
echo "version=$VERSION" >> $GITHUB_OUTPUT
25+
echo "Extracted version: $VERSION"
26+
27+
- uses: googleapis/release-please-action@v4
28+
id: release
29+
with:
30+
config-file: .github/release-please-config.json
31+
manifest-file: .github/.release-please-manifest.json
32+
target-branch: ${{ github.ref_name }}
33+
release-as: ${{ steps.extract-version.outputs.version }}

0 commit comments

Comments
 (0)