Repository navigation
90 lines (81 loc) · 3.67 KB
/
Copy pathrelease_rc_python.yml
File metadata and controls
90 lines (81 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# 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@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
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