From a459ce017e2bb3860d5b05904e17ebec5fe1dc01 Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Thu, 19 Feb 2026 01:07:36 +0000 Subject: [PATCH 1/6] feat: add auto-generate models workflow --- .github/workflows/auto-generate.yml | 54 +++++++++++++++++++++++++++++ generate_models.sh | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/auto-generate.yml diff --git a/.github/workflows/auto-generate.yml b/.github/workflows/auto-generate.yml new file mode 100644 index 0000000..42f4ec4 --- /dev/null +++ b/.github/workflows/auto-generate.yml @@ -0,0 +1,54 @@ +name: Auto-generate Models + +on: + repository_dispatch: + types: [spec-release] + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g. v1.2.3)' + required: true + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - 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: ${{ secrets.CROSS_REPO_READ_PAT }} + + - 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=${TAG_VERSION#v} + sed -i "s/^version = ".*"/version = "$PY_VERSION"/" pyproject.toml + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.CROSS_REPO_READ_PAT }} + 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 diff --git a/generate_models.sh b/generate_models.sh index 26afb35..881f15b 100755 --- a/generate_models.sh +++ b/generate_models.sh @@ -8,7 +8,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..." From f42ed0613d65a9c5dc57788e92aad26d46f2f722 Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Thu, 19 Feb 2026 01:33:29 +0000 Subject: [PATCH 2/6] chore: add license header to workflow and script --- .github/workflows/auto-generate.yml | 16 +++++++++++++++- generate_models.sh | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-generate.yml b/.github/workflows/auto-generate.yml index 42f4ec4..9ef5f0e 100644 --- a/.github/workflows/auto-generate.yml +++ b/.github/workflows/auto-generate.yml @@ -1,3 +1,17 @@ +# Copyright 2026 UCP Authors +# +# 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. + name: Auto-generate Models on: @@ -51,4 +65,4 @@ jobs: 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 + base: main \ No newline at end of file diff --git a/generate_models.sh b/generate_models.sh index 881f15b..60aa330 100755 --- a/generate_models.sh +++ b/generate_models.sh @@ -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 From 894bfa5fa5463cc4cb2bca78e7e7f8e3b6b98c2f Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Fri, 6 Mar 2026 04:58:05 +0000 Subject: [PATCH 3/6] chore: switch auto-generate workflow to GitHub App token --- .github/workflows/auto-generate.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-generate.yml b/.github/workflows/auto-generate.yml index 9ef5f0e..caa3796 100644 --- a/.github/workflows/auto-generate.yml +++ b/.github/workflows/auto-generate.yml @@ -27,6 +27,15 @@ 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 @@ -36,7 +45,7 @@ jobs: repository: Universal-Commerce-Protocol/ucp ref: ${{ github.event.client_payload.version || github.event.inputs.version }} path: ucp-repo - token: ${{ secrets.CROSS_REPO_READ_PAT }} + token: ${{ steps.app-token.outputs.token }} - name: Set up Python uses: actions/setup-python@v5 @@ -60,7 +69,7 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: - token: ${{ secrets.CROSS_REPO_READ_PAT }} + 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 }}." From 5c64f1b522758e8c2658f75c6f29a1c358b4fd13 Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Fri, 6 Mar 2026 05:12:48 +0000 Subject: [PATCH 4/6] chore: update version description example to date-based format --- .github/workflows/auto-generate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-generate.yml b/.github/workflows/auto-generate.yml index caa3796..8035832 100644 --- a/.github/workflows/auto-generate.yml +++ b/.github/workflows/auto-generate.yml @@ -20,7 +20,7 @@ on: workflow_dispatch: inputs: version: - description: 'Version to release (e.g. v1.2.3)' + description: 'Version to release (e.g. v2026-03-06)' required: true jobs: From d22f887fc22406b4f9d3c7465e1e2ea03633a172 Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Fri, 6 Mar 2026 12:24:55 +0000 Subject: [PATCH 5/6] fix: consistent versioning and add .gitignore for clean automated PRs --- .github/workflows/auto-generate.yml | 35 +++++------------------------ .gitignore | 5 +++++ 2 files changed, 11 insertions(+), 29 deletions(-) create mode 100644 .gitignore diff --git a/.github/workflows/auto-generate.yml b/.github/workflows/auto-generate.yml index 8035832..d7d14f1 100644 --- a/.github/workflows/auto-generate.yml +++ b/.github/workflows/auto-generate.yml @@ -1,17 +1,3 @@ -# Copyright 2026 UCP Authors -# -# 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. - name: Auto-generate Models on: @@ -20,22 +6,13 @@ on: workflow_dispatch: inputs: version: - description: 'Version to release (e.g. v2026-03-06)' + description: 'Version to release (e.g. v1.2.3)' 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 @@ -45,7 +22,7 @@ jobs: repository: Universal-Commerce-Protocol/ucp ref: ${{ github.event.client_payload.version || github.event.inputs.version }} path: ucp-repo - token: ${{ steps.app-token.outputs.token }} + token: ${{ secrets.CROSS_REPO_READ_PAT }} - name: Set up Python uses: actions/setup-python@v5 @@ -63,15 +40,15 @@ jobs: - name: Update version in pyproject.toml run: | TAG_VERSION="${{ github.event.client_payload.version || github.event.inputs.version }}" - PY_VERSION=${TAG_VERSION#v} - sed -i "s/^version = ".*"/version = "$PY_VERSION"/" pyproject.toml + 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 }} + token: ${{ secrets.CROSS_REPO_READ_PAT }} 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 \ No newline at end of file + base: main diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86e7c96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.venv/ +.ruff_cache/ +__pycache__/ +*.py[cod] +ucp-repo/ From fa162f2be540feb91362529546dbfbc84894a823 Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Fri, 6 Mar 2026 12:29:53 +0000 Subject: [PATCH 6/6] chore: use App token for authentication and remove ucp-repo from .gitignore --- .github/workflows/auto-generate.yml | 19 ++++++++++++++----- .gitignore | 1 - 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/auto-generate.yml b/.github/workflows/auto-generate.yml index d7d14f1..d3ed2a1 100644 --- a/.github/workflows/auto-generate.yml +++ b/.github/workflows/auto-generate.yml @@ -6,13 +6,22 @@ on: workflow_dispatch: inputs: version: - description: 'Version to release (e.g. v1.2.3)' + 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 @@ -22,12 +31,12 @@ jobs: repository: Universal-Commerce-Protocol/ucp ref: ${{ github.event.client_payload.version || github.event.inputs.version }} path: ucp-repo - token: ${{ secrets.CROSS_REPO_READ_PAT }} + token: ${{ steps.app-token.outputs.token }} - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: "3.11" - name: Install uv run: curl -LsSf https://astral.sh/uv/install.sh | sh @@ -40,13 +49,13 @@ jobs: - 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 '-' '.') + 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: ${{ secrets.CROSS_REPO_READ_PAT }} + 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 }}." diff --git a/.gitignore b/.gitignore index 86e7c96..db7a87d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ .ruff_cache/ __pycache__/ *.py[cod] -ucp-repo/