# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # SPDX-License-Identifier: Apache-2.0 # Release Python RC: Run workflow → enter target version (e.g. 0.5.2) → publishes 0.5.2-rc.1, 0.5.2-rc.2, etc. # Creates branch release/py/X.Y.Z-rc.N with bumped versions, pushes it, tags it. Publish workflow (tag-triggered) uses that branch. name: Release Python RC on: workflow_dispatch: inputs: target_version: description: Target version (e.g., 0.5.2) type: string required: true permissions: contents: read jobs: release_rc: runs-on: ubuntu-latest permissions: contents: write steps: # Checkout main so we can branch from it. Token needed for push later. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: token: ${{ secrets.GENKIT_RELEASER_GITHUB_TOKEN }} persist-credentials: false fetch-depth: 0 # Ensure we're on latest main and have tags (for RC numbering) - name: Pull latest & fetch tags run: git pull origin main && git fetch --tags # uv used for uv lock after bump - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 with: enable-cache: true python-version: "3.12" version: "0.6.6" - name: Create release branch & bump version id: rc env: TARGET_VERSION: ${{ inputs.target_version }} run: | set -e TARGET="$TARGET_VERSION" [[ "$TARGET" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Error: target_version must be X.Y.Z"; exit 1; } # Next RC number: find highest existing py/v0.5.2-rc.N, add 1 (or 1 if none) EXISTING=$(git tag -l "py/v${TARGET}-rc.*" 2>/dev/null | sed -n 's/.*-rc\.\([0-9]*\)$/\1/p' | sort -n | tail -1) RC_NUM=$((${EXISTING:-0} + 1)) NEW="${TARGET}-rc.${RC_NUM}" BRANCH="release/py/${NEW}" echo "new=${NEW}" >> $GITHUB_OUTPUT # Read current version from genkit; bump all packages that match CUR=$(grep '^version = ' py/packages/genkit/pyproject.toml | cut -d'"' -f2) git config user.email "genkit-releaser@google.com" && git config user.name "genkit-releaser" git checkout -b "${BRANCH}" cd py for f in packages/*/pyproject.toml; do [ -f "$f" ] && grep -q "version = \"$CUR\"" "$f" && sed -i "s/version = \"$CUR\"/version = \"$NEW\"/" "$f" done uv lock && cd .. git add py/ git diff --staged --quiet && { echo "::error::No version changes - $CUR may not match pyproject.toml files"; exit 1; } git commit -m "chore(py): bump version to $NEW" git push origin HEAD:"refs/heads/${BRANCH}" # Tag points at our release branch so Publish Python (tag-triggered) checks out correct version - name: Create tag & GitHub release env: GH_TOKEN: ${{ secrets.GENKIT_RELEASER_GITHUB_TOKEN }} RC_NEW: ${{ steps.rc.outputs.new }} run: gh release create "py/v${RC_NEW}" --target "release/py/${RC_NEW}" --title "Genkit Python SDK v${RC_NEW}" --notes "Release candidate." --prerelease