From 4b1639d7d8f46d19dbce2598447c5104bc6f38e8 Mon Sep 17 00:00:00 2001 From: "Wei (Jack) Sun" Date: Fri, 6 Feb 2026 21:09:15 -0800 Subject: [PATCH] fix: set release-as at runtime instead of committing to config - Simplify cut-release-branch to just create branch and trigger release-please - Move release-as configuration to release-please workflow at runtime - This avoids polluting main branch when merging back release changes - Update publish-pypi permissions to contents: write --- .github/workflows/cut-release-branch.yml | 26 ++---------------------- .github/workflows/publish-pypi.yml | 2 +- .github/workflows/release-please.yml | 17 ++++++++++++---- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/.github/workflows/cut-release-branch.yml b/.github/workflows/cut-release-branch.yml index 4f3eba3..050d748 100644 --- a/.github/workflows/cut-release-branch.yml +++ b/.github/workflows/cut-release-branch.yml @@ -31,35 +31,13 @@ jobs: exit 1 fi - - name: Create release branch + - name: Create and push release branch run: | BRANCH_NAME="release/v${{ inputs.version }}" git checkout -b "$BRANCH_NAME" + git push origin "$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 - COMMIT_MSG="chore: bump version to ${{ inputs.version }} - - To test this release: - uv pip install git+https://github.com/${{ github.repository }}.git@release/v${{ inputs.version }}" - - git commit -m "$COMMIT_MSG" - git push origin "release/v${{ inputs.version }}" - - name: Trigger Release Please env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 9a2192f..5f23919 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -9,7 +9,7 @@ on: type: string permissions: - contents: read + contents: write pull-requests: write jobs: diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index a9aae82..4cc62f5 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -19,8 +19,8 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - name: Determine version - id: version + - name: Determine version and branch + id: vars run: | if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then VERSION="${{ inputs.version }}" @@ -33,10 +33,19 @@ jobs: echo "branch=$BRANCH" >> $GITHUB_OUTPUT echo "Version: $VERSION, Branch: $BRANCH" + - uses: actions/checkout@v4 + with: + ref: ${{ steps.vars.outputs.branch }} + + - name: Set release-as version + run: | + jq --arg version "${{ steps.vars.outputs.version }}" \ + '.packages["."]["release-as"] = $version' \ + .github/release-please-config.json > tmp.json && mv tmp.json .github/release-please-config.json + - 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: ${{ steps.version.outputs.branch }} - release-as: ${{ steps.version.outputs.version }} + target-branch: ${{ steps.vars.outputs.branch }}