Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions .github/workflows/publish_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,13 @@ jobs:
echo "::endgroup::"
done

# Python-floor shim (genkit 0.3.0): gives Python <= 3.9 users a clear
# upgrade message instead of resolving an unrelated pre-transfer
# package. sdist ONLY - a wheel would install as an empty package on
# old Pythons. skip-existing makes this a no-op after first publish.
# See floor-shim/README.md.
echo "::group::floor-shim (sdist only)"
if uv build --sdist floor-shim --out-dir dist/; then
echo "Build succeeded: floor-shim"
else
echo "::error::Build failed: floor-shim"
FAILED+=("floor-shim")
fi
echo "::endgroup::"

if [ ${#FAILED[@]} -gt 0 ]; then
echo "::error::Failed packages: ${FAILED[*]}"
exit 1
fi

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
packages-dir: dist/
verbose: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ jobs:
mkdir -p "$SPEC_DIR"
curl -sSfL https://raw.githubusercontent.com/genkit-ai/genkit/main/tests/specs/agent.yaml -o "$SPEC_DIR/agent.yaml"
curl -sSfL https://raw.githubusercontent.com/genkit-ai/genkit/main/tests/specs/generate.yaml -o "$SPEC_DIR/generate.yaml"
curl -sSfL https://raw.githubusercontent.com/genkit-ai/genkit/main/genkit-tools/genkit-schema.json -o "$SPEC_DIR/genkit-schema.json"
echo "GENKIT_SPECS_DIR=$SPEC_DIR" >> "$GITHUB_ENV"

- name: Run tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ wheels/

*.bak
release-manifest.json
genkit-tools/
2 changes: 1 addition & 1 deletion bin/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
# SPDX-License-Identifier: Apache-2.0

# Shared helpers for py/bin scripts. Source with: . "$(dirname "$0")/_common.sh"
# Shared helpers for bin scripts. Source with: . "$(dirname "$0")/_common.sh"

# Colors (CYAN exported for scripts that source this file)
RED='\033[0;31m'
Expand Down
2 changes: 1 addition & 1 deletion bin/build_dists
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PY_DIR="${TOP_DIR}"
# This includes packages, plugins, samples, and tests
PROJECT_DIRS=()
while IFS= read -r -d '' pyproject; do
# Get the directory containing pyproject.toml, relative to py/
# Get the directory containing pyproject.toml, relative to repo root
project_dir=$(dirname "${pyproject}")
project_dir="${project_dir#"${PY_DIR}"/}"
PROJECT_DIRS+=("$project_dir")
Expand Down
4 changes: 2 additions & 2 deletions bin/bump_version
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ else
echo -e " 1. Write the release notes in notes.md"
echo -e " 2. Open the release PR:"
echo -e " ${CYAN}git commit -am \"chore(py): release Python SDK v$NEW_VERSION\"${NC}"
echo -e " ${CYAN}gh pr create --base main --title \"chore(py): release Python SDK v$NEW_VERSION\" --body-file notes.md --label python${NC}"
echo -e " ${CYAN}gh pr create --base main --title \"chore: release v$NEW_VERSION\" --body-file notes.md${NC}"
echo -e " 3. Once merged, release it (add --dry-run to check first):"
echo -e " ${CYAN}py/bin/create_release $NEW_VERSION <pr-number>${NC}"
echo -e " ${CYAN}bin/create_release $NEW_VERSION <pr-number>${NC}"
fi
26 changes: 13 additions & 13 deletions bin/create_release
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
# Tag and publish a stable Python SDK release from its merged release PR.
# The PR's description is published as the release notes.
#
# py/bin/create_release <version> <pr-number> [--dry-run]
# bin/create_release <version> <pr-number> [--dry-run]
#
# Steps and checks: py/docs/release_playbook.md
# Steps and checks: docs/release_playbook.md
# Exit codes: 0 ok, 1 usage/environment, 2 a check failed (nothing changed).

set -euo pipefail

REPO="genkit-ai/genkit"
REPO="genkit-ai/genkit-python"

usage() {
cat <<USAGE
Usage: py/bin/create_release <version> <pr-number> [--dry-run]
Usage: bin/create_release <version> <pr-number> [--dry-run]

Tags and publishes a Genkit Python SDK release from its merged release PR.

<version> X.Y.Z, as set by py/bin/bump_version
<pr-number> Merged release PR titled "chore(py): release Python SDK v<version>".
<version> X.Y.Z, as set by bin/bump_version
<pr-number> Merged release PR titled "chore: release v<version>" or "chore(py): release Python SDK v<version>".
Its description becomes the release notes.
--dry-run Run the checks without tagging or publishing

Expand All @@ -59,24 +59,24 @@ for arg in "$@"; do
*)
if [ -z "$VERSION" ]; then VERSION="$arg"
elif [ -z "$PR_NUMBER" ]; then PR_NUMBER="$arg"
else die "unexpected argument '$arg'" "Usage: py/bin/create_release <version> <pr-number> [--dry-run]"
else die "unexpected argument '$arg'" "Usage: bin/create_release <version> <pr-number> [--dry-run]"
fi
;;
esac
done

[ -n "$VERSION" ] && [ -n "$PR_NUMBER" ] ||
die "missing arguments" "Usage: py/bin/create_release <version> <pr-number> [--dry-run]"
die "missing arguments" "Usage: bin/create_release <version> <pr-number> [--dry-run]"
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ||
die "version must be X.Y.Z, got '$VERSION'" "For release candidates, use the \"Release Python RC\" workflow."
[[ "$PR_NUMBER" =~ ^[0-9]+$ ]] ||
die "PR number must be numeric, got '$PR_NUMBER'"

command -v gh >/dev/null 2>&1 || die "GitHub CLI not found" "Install it from https://cli.github.com"
gh auth status >/dev/null 2>&1 || die "GitHub CLI is not authenticated" "Run: gh auth login"
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
cd "$(dirname "${BASH_SOURCE[0]}")/.."

TAG="py/v${VERSION}"
TAG="v${VERSION}"
TITLE="chore(py): release Python SDK v${VERSION}"

PR_INFO=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json state,baseRefName,mergeCommit,url,title \
Expand Down Expand Up @@ -105,10 +105,10 @@ else
pass "PR merged into main"
fi

if [ "$PR_TITLE" = "$TITLE" ]; then
if [ "$PR_TITLE" = "$TITLE" ] || [ "$PR_TITLE" = "chore: release v${VERSION}" ] || [ "$PR_TITLE" = "chore: release Python SDK v${VERSION}" ]; then
pass "Title matches"
else
fail "Title is \"$PR_TITLE\"" "Expected \"$TITLE\". Pass the PR that bumped to $VERSION; rename only if this is it."
fail "Title is \"$PR_TITLE\"" "Expected \"$TITLE\" or \"chore: release v${VERSION}\". Pass the PR that bumped to $VERSION; rename only if this is it."
fi

if [ -n "$(printf '%s' "$NOTES" | tr -d '[:space:]')" ]; then
Expand All @@ -124,7 +124,7 @@ if [ -n "$MERGE_SHA" ]; then
FOUND=""
TOTAL=0
NWRONG=0
for toml in $(git ls-tree -r --name-only "$MERGE_SHA" -- py/packages | grep -E '^py/packages/[^/]+/pyproject\.toml$'); do
for toml in $(git ls-tree -r --name-only "$MERGE_SHA" -- packages | grep -E '^packages/[^/]+/pyproject\.toml$'); do
v=$(git show "$MERGE_SHA:$toml" | sed -n 's/^version *= *"\(.*\)"/\1/p' | head -1)
TOTAL=$((TOTAL + 1))
if [ "$v" != "$VERSION" ]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/run_python_security_checks
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PY_DIR="$(cd "${BIN_DIR}/.." && pwd)"
echo "--- 🐍 Running Python Security Checks (PySentry) ---"

# Run pysentry-rs via uv
# The --directory flag ensures we run in the context of the `py` directory.
# The --directory flag ensures we run in the context of the repository root.
uv run --directory "${PY_DIR}" pysentry-rs .

echo "--- ✅ Security Checks Passed ---"
2 changes: 1 addition & 1 deletion docs/migrating-from-0.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ uv add 'genkit-vertexai[openai]' # Llama, Mistral and other OpenAI-compatib
You can point a coding agent at this page:

```text
Migrate this project from Genkit Python 0.12 to 0.13 by following https://github.com/genkit-ai/genkit/blob/main/py/docs/migrating-from-0.12.md.
Migrate this project from Genkit Python 0.12 to 0.13 by following https://github.com/genkit-ai/genkit-python/blob/main/docs/migrating-from-0.12.md.
Apply every section whose old code appears in this codebase, then run the type checker and tests and list anything you couldn't migrate.
```

Expand Down
28 changes: 14 additions & 14 deletions docs/release_playbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,44 @@ Use the **Release Python RC** workflow in GitHub Actions:

**What the workflow does:**

1. Creates branch `release/py/X.Y.Z-rc.1` (one branch per RC)
1. Creates branch `release/X.Y.Z-rc.1` (one branch per RC)
2. Bumps all `pyproject.toml` versions from current to the RC version
3. Commits and pushes to that branch
4. Creates tag `py/vX.Y.Z-rc.1` pointing at the release branch
4. Creates tag `vX.Y.Z-rc.1` pointing at the release branch
5. Tag push triggers **Publish Python**, which builds and publishes to PyPI

No PR required.

**If you need to re-run publish** (e.g., it failed): Go to Actions → Publish Python → Run workflow → select the release branch (e.g., `release/py/X.Y.Z-rc.1`) from the branch dropdown → Run.
**If you need to re-run publish** (e.g., it failed): Go to Actions → Publish Python → Run workflow → select the release branch (e.g., `release/X.Y.Z-rc.1`) from the branch dropdown → Run.

## Stable release steps

There is one path. `create_release` refuses to run unless every step below was followed.

1. `py/bin/bump_version X.Y.Z` on a branch from main. It bumps every `pyproject.toml` and `uv.lock`.
2. Open a PR to main titled exactly `chore(py): release Python SDK vX.Y.Z`. Its description is the release notes, published word for word.
1. `bin/bump_version X.Y.Z` on a branch from main. It bumps every `pyproject.toml` and `uv.lock`.
2. Open a PR to main titled `chore: release vX.Y.Z` or `chore(py): release Python SDK vX.Y.Z`. Its description is the release notes, published word for word.
3. Get it approved and merged.
4. `py/bin/create_release X.Y.Z <PR_NUMBER> --dry-run`, then without `--dry-run`.
5. Approve the publish at <https://github.com/genkit-ai/genkit/actions/workflows/publish_python.yml>. The tag push already started it; don't run it by hand.
4. `bin/create_release X.Y.Z <PR_NUMBER> --dry-run`, then without `--dry-run`.
5. Approve the publish at <https://github.com/genkit-ai/genkit-python/actions/workflows/publish_python.yml>. The tag push already started it; don't run it by hand.
6. `pip index versions genkit` shows X.Y.Z.

`create_release` runs every check before it changes anything and prints a fix for each failure:

- **Merged into main**: the PR is merged, and into main
- **Title**: exactly `chore(py): release Python SDK vX.Y.Z`
- **Title**: matches `chore: release vX.Y.Z` or `chore(py): release Python SDK vX.Y.Z`
- **Release notes**: the description isn't empty
- **Versions**: every `py/packages/*/pyproject.toml` is at X.Y.Z in the merge commit
- **Tag**: `py/vX.Y.Z` doesn't exist yet
- **Versions**: every `packages/*/pyproject.toml` is at X.Y.Z in the merge commit
- **Tag**: `vX.Y.Z` doesn't exist yet

It tags the PR's merge commit, not the tip of main, so anything merged later stays out of the release. Exit codes: `0` ok, `1` usage or environment, `2` a check failed and nothing changed.

To fix notes after release, edit the GitHub release: `gh release edit py/vX.Y.Z --notes-file notes.md`. The PR description isn't read again.
To fix notes after release, edit the GitHub release: `gh release edit vX.Y.Z --notes-file notes.md`. The PR description isn't read again.

## After 0.13.0: retire genkit-evaluators

genkit 1.0 removes evaluators (#6947). genkit-evaluators 0.13.0 is the last release and requires `genkit>=0.13.0,<1`. `bump_version` writes that floor; the steps above need no hand edits.

Every earlier release (0.9.0 through 0.12.0) requires `genkit` with no upper bound. The cap alone isn't enough: when 0.13.0 conflicts with genkit 1.0, pip and uv backtrack to an older genkit-evaluators, and those accept genkit 1.0. So, once `py/v0.13.0` is on PyPI:
Every earlier release (0.9.0 through 0.12.0) requires `genkit` with no upper bound. The cap alone isn't enough: when 0.13.0 conflicts with genkit 1.0, pip and uv backtrack to an older genkit-evaluators, and those accept genkit 1.0. So, once `v0.13.0` is on PyPI:

1. Yank genkit-evaluators 0.9.0, 0.10.0, 0.11.0 and 0.12.0 on PyPI (Manage → Releases → Options → Yank). Reason: `unbounded genkit dependency; use 0.13.0`.
2. Verify in a fresh venv:
Expand All @@ -67,7 +67,7 @@ Resolvers skip yanked versions unless pinned with `==`, so existing exact pins k

## Workflow: `publish_python.yml`

**Triggers:** Tag push (`py/v*`) or manual `workflow_dispatch`. When triggered by tag, it checks out the tag (which points at the release branch). When run manually, **select the release branch** (e.g., `release/py/X.Y.Z-rc.1`) from the "Use workflow from" dropdown — otherwise it will build from main.
**Triggers:** Tag push (`v*`) or manual `workflow_dispatch`. When triggered by tag, it checks out the tag (which points at the release branch). When run manually, **select the release branch** (e.g., `release/X.Y.Z-rc.1`) from the "Use workflow from" dropdown — otherwise it will build from main.

**Two jobs:** publish → verify

Expand All @@ -76,4 +76,4 @@ Resolvers skip yanked versions unless pinned with `==`, so existing exact pins k

## Auth

OIDC trusted publishing. No API tokens. PyPI is configured to trust: Owner `firebase`, Repository `genkit`, Workflow `publish_python.yml`, Environment `pypi_github_publishing`. Already set up. Don't rename the workflow file or this breaks.
OIDC trusted publishing. No API tokens. PyPI is configured to trust: Owner `genkit-ai`, Repository `genkit-python`, Workflow `publish_python.yml`, Environment `pypi_github_publishing`. Don't rename the workflow file or this breaks.
2 changes: 0 additions & 2 deletions floor-shim/.gitignore

This file was deleted.

78 changes: 0 additions & 78 deletions floor-shim/README.md

This file was deleted.

Loading
Loading