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
62 changes: 62 additions & 0 deletions .github/workflows/auto-generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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, js-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 Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Generate Models
run: npm run generate -- ucp-repo/source

- name: Update version in package.json
run: |
TAG_VERSION="${{ github.event.client_payload.version || github.event.inputs.version }}"
JS_VERSION=$(echo ${TAG_VERSION#v} | tr '-' '.')
npm version "$JS_VERSION" --no-git-tag-version

- 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
*.log
16 changes: 5 additions & 11 deletions generate_models.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# Copyright 2026 UCP Authors

if [[ -z "$1" ]]; then
echo "Error: spec directory path is required."
Expand All @@ -15,15 +16,8 @@ quicktype \
--src "$SPEC_DIR"/discovery/*.json \
--src "$SPEC_DIR"/schemas/shopping/*.json \
--src "$SPEC_DIR"/schemas/shopping/types/*.json \
--src "$SPEC_DIR/schemas/shopping/ap2_mandate.json#/\$defs/complete_request_with_ap2" \
--src "$SPEC_DIR/schemas/shopping/ap2_mandate.json#/\$defs/checkout_response_with_ap2" \
--src "$SPEC_DIR/schemas/shopping/buyer_consent.create_req.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/buyer_consent.update_req.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/buyer_consent_resp.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/discount.create_req.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/discount.update_req.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/discount_resp.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/fulfillment.create_req.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/fulfillment.update_req.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/fulfillment_resp.json#/\$defs/checkout" \
--src "$SPEC_DIR/schemas/shopping/ap2_mandate.json#/\$defs/dev.ucp.shopping.checkout" \
--src "$SPEC_DIR/schemas/shopping/buyer_consent.json#/\$defs/dev.ucp.shopping.checkout" \
--src "$SPEC_DIR/schemas/shopping/discount.json#/\$defs/dev.ucp.shopping.checkout" \
--src "$SPEC_DIR/schemas/shopping/fulfillment.json#/\$defs/dev.ucp.shopping.checkout" \
-o src/spec_generated.ts
Loading