# 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: Setup releasekit environment
#
# Handles all the boilerplate that every releasekit job needs:
# 1. Checkout with full history and tags
# 2. Install uv + Python
# 3. Install releasekit with AI plugin extras
# 4. (Optional) Install Ollama and cache models
# 5. Configure git identity for tag/PR creation
#
# Usage:
#
# - uses: ./.github/actions/setup-releasekit
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# releasekit-dir: py/tools/releasekit
# ollama-models: "gemma3:4b"
#
# ══════════════════════════════════════════════════════════════════════
name: Setup ReleaseKit
description: >-
Checkout, install uv + releasekit + Ollama, and configure git identity.
inputs:
token:
description: >-
GitHub token for checkout. Needs write access for tags and PRs.
required: true
releasekit-dir:
description: >-
Path to the releasekit tool directory (relative to repo root).
required: false
default: py/tools/releasekit
python-version:
description: Python version to install.
required: false
default: "3.12"
enable-ollama:
description: >-
Set to "false" to skip Ollama installation, model pulling,
and AI plugin extras entirely. Useful for jobs that don't
need AI features (e.g. publish, verify).
required: false
default: "false"
ai-extras:
description: >-
Space-separated list of pip extras for AI plugins
(e.g. "ollama google-genai"). Empty string skips extras.
Ignored when enable-ollama is "false".
required: false
default: "ollama google-genai"
ollama-models:
description: >-
Space-separated Ollama model tags to pull and cache.
Empty string skips Ollama setup entirely.
Ignored when enable-ollama is "false".
required: false
default: "gemma3:4b"
git-user-name:
description: Git user.name for commits/tags.
required: false
default: "github-actions[bot]"
git-user-email:
description: Git user.email for commits/tags.
required: false
default: "github-actions[bot]@users.noreply.github.com"
install-system-deps:
description: >-
Install system build dependencies (build-essential, libffi-dev).
Set to "true" for jobs that build Python wheels.
required: false
default: "false"
workspace-dir:
description: >-
Path to the workspace root for installing workspace dependencies.
Empty string skips workspace install.
required: false
default: ""
runs:
using: composite
steps:
# ── 1. Checkout ─────────────────────────────────────────────────
- name: Checkout with full history
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
token: ${{ inputs.token }}
# ── 2. System dependencies (optional) ───────────────────────────
- name: Install system dependencies
if: inputs.install-system-deps == 'true'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential libffi-dev
# ── 3. uv + Python ──────────────────────────────────────────────
- name: Install uv and setup Python
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ inputs.python-version }}
# ── 4. Workspace dependencies (optional) ────────────────────────
- name: Install workspace dependencies
if: inputs.workspace-dir != ''
shell: bash
working-directory: ${{ inputs.workspace-dir }}
run: uv sync --no-dev
# ── 5. Install releasekit ───────────────────────────────────────
- name: Install releasekit
shell: bash
working-directory: ${{ inputs.releasekit-dir }}
env:
AI_EXTRAS: ${{ inputs.enable-ollama == 'true' && inputs.ai-extras || '' }}
run: |
if [ -n "$AI_EXTRAS" ]; then
# Convert "ollama google-genai" → ("--extra" "ollama" "--extra" "google-genai")
EXTRA_FLAGS=()
for extra in $AI_EXTRAS; do
EXTRA_FLAGS+=(--extra "$extra")
done
uv sync "${EXTRA_FLAGS[@]}"
else
uv sync
fi
# ── 6. Ollama (optional) ────────────────────────────────────────
- name: Setup Ollama with model caching
if: inputs.enable-ollama == 'true' && inputs.ollama-models != ''
uses: ./.github/actions/setup-ollama
with:
models: ${{ inputs.ollama-models }}
# ── 7. Git identity ─────────────────────────────────────────────
- name: Configure git identity
shell: bash
run: |
git config user.name "${{ inputs.git-user-name }}"
git config user.email "${{ inputs.git-user-email }}"