Skip to content
Open
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
63 changes: 63 additions & 0 deletions .github/workflows/auto-generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Auto-generate Models

on:
repository_dispatch:
types: [spec-release]
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. v2026-03-06)"
required: true

jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Generate Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: "ucp, python-sdk"

- name: Checkout SDK
uses: actions/checkout@v4

- name: Checkout Specification
uses: actions/checkout@v4
with:
repository: Universal-Commerce-Protocol/ucp
ref: ${{ github.event.client_payload.version || github.event.inputs.version }}
path: ucp-repo
token: ${{ steps.app-token.outputs.token }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Generate Models
run: |
export SCHEMA_DIR="ucp-repo/source/schemas"
./generate_models.sh

- name: Update version in pyproject.toml
run: |
TAG_VERSION="${{ github.event.client_payload.version || github.event.inputs.version }}"
PY_VERSION=$(echo ${TAG_VERSION#v} | tr "-" ".")
sed -i 's/^version = ".*"/version = "'$PY_VERSION'"/' pyproject.toml

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.app-token.outputs.token }}
commit-message: "chore: update models to ${{ github.event.client_payload.version || github.event.inputs.version }}"
title: "Update models to ${{ github.event.client_payload.version || github.event.inputs.version }}"
body: "This PR updates the SDK models based on the latest specification release ${{ github.event.client_payload.version || github.event.inputs.version }}."
branch: "auto-update-models-${{ github.event.client_payload.version || github.event.inputs.version }}"
base: main
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.venv/
.ruff_cache/
__pycache__/
*.py[cod]
3 changes: 2 additions & 1 deletion generate_models.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# Copyright 2026 UCP Authors
# Generate Pydantic models from UCP JSON Schemas

# Ensure we are in the script's directory
Expand All @@ -8,7 +9,7 @@ cd "$(dirname "$0")" || exit
OUTPUT_DIR="src/ucp_sdk/models"

# Schema directory (relative to this script)
SCHEMA_DIR="../../spec/"
SCHEMA_DIR="${SCHEMA_DIR:-../../spec/}"

echo "Generating Pydantic models from $SCHEMA_DIR..."

Expand Down
Loading