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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
105 changes: 105 additions & 0 deletions .github/actions/setup-ollama/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# 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

# ══════════════════════════════════════════════════════════════════════
# Reusable composite action: Install Ollama and cache models
#
# Installs the Ollama server, starts it in the background, pulls the
# requested models, and caches them between CI runs using
# actions/cache. The cache key includes the model list so pulling
# different models in different workflows produces separate caches.
#
# Usage:
#
# - uses: ./.github/actions/setup-ollama
# with:
# models: "gemma3:4b"
#
# The Ollama model blobs live under ~/.ollama/models. The cache
# restores this directory before pulling, so only new or updated
# models trigger a download.
# ══════════════════════════════════════════════════════════════════════

name: Setup Ollama
description: Install Ollama, pull models, and cache them between runs.

inputs:
models:
description: >-
Space-separated list of Ollama model tags to pull
(e.g. "gemma3:4b").
required: true
ollama-version:
description: >-
Ollama version to install. "latest" fetches the newest release.
required: false
default: latest

runs:
using: composite
steps:
# ── 1. Restore cached models ────────────────────────────────────
- name: Restore Ollama model cache
id: cache-ollama
uses: actions/cache@0c45773b623bea8c8e75f6c82b208d3cf829445e # v4.2.0
with:
path: ~/.ollama/models
# Key includes the model list so different model sets get
# separate caches. The runner OS is included because model
# blobs are platform-independent but the directory layout
# could theoretically differ.
key: ollama-models-${{ runner.os }}-${{ inputs.models }}

# ── 2. Install Ollama ───────────────────────────────────────────
- name: Install Ollama
shell: bash
run: |
curl -fsSL https://ollama.com/install.sh | sh
echo "Ollama version: $(ollama --version)"

# ── 3. Start Ollama server ──────────────────────────────────────
- name: Start Ollama server
shell: bash
run: |
ollama serve &
# Wait for the server to be ready (up to 30 seconds).
for i in $(seq 1 30); do
if curl -sf http://localhost:11434/api/tags >/dev/null 2>&1; then
echo "Ollama server is ready"
break
fi
sleep 1
done

# Final check to ensure the server is ready before proceeding.
if ! curl -sf http://localhost:11434/api/tags >/dev/null 2>&1; then
echo "::error::Ollama server failed to start after 30 seconds."
exit 1
fi

# ── 4. Pull models (skips if already cached) ────────────────────
- name: Pull Ollama models
shell: bash
env:
OLLAMA_MODELS: ${{ inputs.models }}
run: |
for model in $OLLAMA_MODELS; do
echo "::group::Pulling $model"
ollama pull "$model"
echo "::endgroup::"
done
echo "Available models:"
ollama list
61 changes: 61 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deploy Python API Docs

on:
workflow_dispatch:

permissions:
contents: read

jobs:
deploy-docs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout genkit-python
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
path: genkit-python

- name: Install uv
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5
with:
version: "latest"

- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version-file: "genkit-python/.python-version"

- name: Install dependencies
working-directory: genkit-python
run: uv sync --all-extras --dev

- name: Build Docs
working-directory: genkit-python
run: uv run mkdocs build

- name: Checkout hosting-templates
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
repository: genkit-ai/hosting-templates
path: hosting-templates

- name: Copy Docs to hosting-templates
run: |
mkdir -p hosting-templates/api-ref/py-public
cp -R genkit-python/site/* hosting-templates/api-ref/py-public/

- name: Setup Node.js (for Firebase CLI)
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'

- name: Install Firebase CLI
run: npm install -g firebase-tools

- name: Deploy to Firebase Hosting
working-directory: hosting-templates
run: firebase deploy --only hosting:py-prod --project project-kaizen-404017
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
115 changes: 115 additions & 0 deletions .github/workflows/publish_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# 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 v0.7.0 or manually via workflow_dispatch.
# Auth uses PyPI trusted publishing (OIDC) — no API tokens needed.

name: Publish Python

on:
push:
tags:
- "v*"
workflow_dispatch:

concurrency:
group: publish-python-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi_github_publishing
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5
with:
enable-cache: true
python-version: "3.12"
version: "0.6.6"

- name: Build and publish packages
run: |
set -uo pipefail

# Publish all core and plugin packages for v0.9.0 release.
PACKAGES=(
packages/genkit
packages/genkit-anthropic
packages/genkit-django
packages/genkit-evaluators
packages/genkit-fastapi
packages/genkit-flask
packages/genkit-google-cloud
packages/genkit-google-genai
packages/genkit-middleware
packages/genkit-ollama
packages/genkit-openai
packages/genkit-vertexai
)

FAILED=()
for pkg in "${PACKAGES[@]}"; do
echo "::group::$pkg"
if uv build "$pkg" --out-dir dist/; then
echo "Build succeeded: $pkg"
else
echo "::error::Build failed: $pkg"
FAILED+=("$pkg")
fi
echo "::endgroup::"
done

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

echo "::group::Build tombstone packages"
python3 scripts/publish_tombstones.py --dist-dir dist/
echo "::endgroup::"

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: dist/
verbose: true
skip-existing: true

verify:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
- name: Smoke test
env:
TAG: ${{ github.ref_name }}
run: |
VERSION="${TAG#v}"
pip install "genkit==${VERSION}"
python -c "from genkit import Genkit; Genkit(); print('ok')"
Loading
Loading