# 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
# Publish all Python packages to PyPI.
#
# Triggered by pushing a tag like py/v0.7.0 or manually via workflow_dispatch.
# Packages are built and published in dependency order.
# Auth uses PyPI trusted publishing (OIDC) — no API tokens needed.
name: Publish Python
on:
push:
tags:
- "py/v*"
workflow_dispatch:
inputs:
dry_run:
description: "Build but do not publish"
type: boolean
default: false
target:
description: "Publish target"
type: choice
default: pypi
options:
- pypi
- testpypi
concurrency:
group: publish-python-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
environment:
name: ${{ (inputs.target == 'testpypi' && 'testpypi') || 'pypi_github_publishing' }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Build and publish
env:
DRY_RUN: ${{ inputs.dry_run }}
PUBLISH_URL: ${{ inputs.target == 'testpypi' && 'https://test.pypi.org/legacy/' || '' }}
run: |
set -euo pipefail
# Packages in dependency order.
PACKAGES=(
py/packages/genkit
py/plugins/anthropic
py/plugins/compat-oai
py/plugins/dev-local-vectorstore
py/plugins/google-cloud
py/plugins/google-genai
py/plugins/ollama
py/plugins/firebase
py/plugins/flask
py/plugins/vertex-ai
)
PUBLISH_ARGS=()
if [ -n "$PUBLISH_URL" ]; then
PUBLISH_ARGS+=(--publish-url "$PUBLISH_URL")
fi
for pkg in "${PACKAGES[@]}"; do
echo "::group::$pkg"
uv build "$pkg" --out-dir dist/
if [ "$DRY_RUN" != "true" ]; then
uv publish "${PUBLISH_ARGS[@]}" dist/*
rm -rf dist/
fi
echo "::endgroup::"
done
verify:
needs: publish
if: inputs.dry_run != true
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Smoke test
env:
TAG: ${{ github.ref_name }}
run: |
VERSION="${TAG#py/v}"
pip install "genkit==${VERSION}"
python -c "from genkit.ai import Genkit; print('ok')"