From 2e40acd403cc3fd6f785025846d32e03fcf945e0 Mon Sep 17 00:00:00 2001 From: "Wei (Jack) Sun" Date: Tue, 3 Feb 2026 20:36:28 -0800 Subject: [PATCH] ci: add release-please automation with versioned branch workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .github/.release-please-manifest.json | 3 + .github/release-please-config.json | 24 ++++++++ .github/workflows/cut-release-branch.yml | 72 ++++++++++++++++++++++++ .github/workflows/publish-pypi.yml | 34 +++++++++++ .github/workflows/release-please.yml | 33 +++++++++++ 5 files changed, 166 insertions(+) create mode 100644 .github/.release-please-manifest.json create mode 100644 .github/release-please-config.json create mode 100644 .github/workflows/cut-release-branch.yml create mode 100644 .github/workflows/publish-pypi.yml create mode 100644 .github/workflows/release-please.yml diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 0000000..2be9c43 --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.2.0" +} diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 0000000..8c9278a --- /dev/null +++ b/.github/release-please-config.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "python", + "package-name": "google-adk-community", + "draft": true, + "changelog-path": "CHANGELOG.md", + "skip-github-release": false, + "changelog-sections": [ + {"type": "feat", "section": "Features"}, + {"type": "fix", "section": "Bug Fixes"}, + {"type": "perf", "section": "Performance Improvements"}, + {"type": "refactor", "section": "Code Refactoring"}, + {"type": "docs", "section": "Documentation"}, + {"type": "test", "section": "Tests", "hidden": true}, + {"type": "build", "section": "Build System", "hidden": true}, + {"type": "ci", "section": "CI/CD", "hidden": true}, + {"type": "style", "section": "Styles", "hidden": true}, + {"type": "chore", "section": "Miscellaneous Chores", "hidden": true} + ] + } + } +} diff --git a/.github/workflows/cut-release-branch.yml b/.github/workflows/cut-release-branch.yml new file mode 100644 index 0000000..763cd19 --- /dev/null +++ b/.github/workflows/cut-release-branch.yml @@ -0,0 +1,72 @@ +name: Cut Release Branch + +on: + workflow_dispatch: + inputs: + version: + description: 'Version for the release (e.g., 0.3.0)' + required: true + type: string + +permissions: + contents: write + +jobs: + cut-branch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + + - name: Validate version format + run: | + if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then + echo "Error: Version must be in format X.Y.Z (e.g., 0.3.0)" + exit 1 + fi + + - name: Create release branch + run: | + BRANCH_NAME="release/v${{ inputs.version }}" + git checkout -b "$BRANCH_NAME" + echo "Created branch: $BRANCH_NAME" + + - name: Bump version + run: | + # Update version.py + sed -i 's/__version__ = ".*"/__version__ = "${{ inputs.version }}"/' src/google/adk_community/version.py + + # Update release-please manifest + echo '{".": "${{ inputs.version }}"}' > .github/.release-please-manifest.json + + echo "Bumped version to ${{ inputs.version }}" + + - name: Commit version bump + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add src/google/adk_community/version.py .github/.release-please-manifest.json + git commit -m "chore: bump version to ${{ inputs.version }}" + git push origin "release/v${{ inputs.version }}" + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Build wheel + run: uv build + + - name: Upload wheel for testing + uses: actions/upload-artifact@v4 + with: + name: dist-${{ inputs.version }} + path: dist/ + retention-days: 30 diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..3d17578 --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,34 @@ +name: Publish to PyPI + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name }} + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Build package + run: uv build + + - name: Publish to PyPI + env: + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: uv publish diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..c3bf1be --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,33 @@ +name: Release Please + +on: + push: + branches: + - 'release/**' + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - name: Extract version from branch name + id: extract-version + run: | + # Branch name is like "release/v0.3.0", extract "0.3.0" + VERSION="${GITHUB_REF_NAME#release/v}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Extracted version: $VERSION" + + - uses: googleapis/release-please-action@v4 + id: release + with: + config-file: .github/release-please-config.json + manifest-file: .github/.release-please-manifest.json + target-branch: ${{ github.ref_name }} + release-as: ${{ steps.extract-version.outputs.version }}