Skip to content

Commit 362a6be

Browse files
chore(regenerate): add v3-dev regenerate workflow
1 parent fa4e9a9 commit 362a6be

1 file changed

Lines changed: 117 additions & 0 deletions

File tree

‎.github/workflows/regenerate.yml‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
2+
name: Regenerate
3+
4+
# Keep this workflow on main for dispatch registration; generation targets v3-dev.
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: Spec version (e.g. 1.2.3)
10+
required: true
11+
type: string
12+
asset_url:
13+
description: GitHub API URL for the spec tarball release asset
14+
required: true
15+
type: string
16+
spec_file:
17+
description: Spec filename inside the released spec tarball
18+
required: true
19+
type: string
20+
21+
jobs:
22+
regenerate:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write
26+
pull-requests: write
27+
env:
28+
SPEC_VERSION: ${{ github.event.inputs.version }}
29+
ASSET_URL: ${{ github.event.inputs.asset_url }}
30+
SPEC_FILE: ${{ github.event.inputs.spec_file || 'upcloud-public-openapi.json' }}
31+
32+
steps:
33+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34+
with:
35+
ref: v3-dev
36+
fetch-depth: 1
37+
38+
- name: Setup uv
39+
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
40+
with:
41+
python-version: 3.14
42+
43+
- name: Download OpenAPI Spec
44+
env:
45+
SPECS_ACCESS_PAT: ${{ secrets.SPECS_ACCESS_PAT }}
46+
run: |
47+
set -euo pipefail
48+
49+
if [ -z "$SPEC_VERSION" ]; then
50+
echo "ERROR: Missing workflow_dispatch input: version"
51+
exit 1
52+
fi
53+
54+
if [ -z "$ASSET_URL" ]; then
55+
echo "ERROR: Missing asset_url"
56+
exit 1
57+
fi
58+
59+
if [ -z "$SPEC_FILE" ]; then
60+
echo "ERROR: Missing spec_file"
61+
exit 1
62+
fi
63+
64+
: "${SPECS_ACCESS_PAT:?ERROR: SPECS_ACCESS_PAT secret is not set}"
65+
66+
echo "Spec version: $SPEC_VERSION"
67+
echo "Spec file: $SPEC_FILE"
68+
echo "Downloading from ASSET_URL='$ASSET_URL'"
69+
70+
mkdir -p generator/openapi
71+
72+
curl --fail -L \
73+
--retry 5 \
74+
--retry-all-errors \
75+
--retry-delay 2 \
76+
-H "Authorization: Bearer $SPECS_ACCESS_PAT" \
77+
-H "Accept: application/octet-stream" \
78+
"$ASSET_URL" \
79+
-o spec.tar.gz
80+
81+
echo "Extracting spec"
82+
rm -rf /tmp/spec-extract
83+
mkdir -p /tmp/spec-extract generator/openapi
84+
85+
if ! tar -tzf spec.tar.gz | grep -Fx "$SPEC_FILE" >/dev/null; then
86+
echo "ERROR: $SPEC_FILE not found in downloaded tarball"
87+
tar -tzf spec.tar.gz
88+
exit 1
89+
fi
90+
91+
tar -xzf spec.tar.gz -C /tmp/spec-extract "$SPEC_FILE"
92+
mv "/tmp/spec-extract/$SPEC_FILE" generator/openapi/spec.json
93+
94+
if [ ! -f generator/openapi/spec.json ]; then
95+
echo "ERROR: spec.json not found after extraction"
96+
find generator/openapi -maxdepth 2 -type f
97+
exit 1
98+
fi
99+
100+
- name: Run generator
101+
run: |
102+
chmod +x generator/scripts/generate.sh
103+
generator/scripts/generate.sh
104+
105+
- name: Update lockfile
106+
run: uv lock
107+
108+
- name: Create PR
109+
uses: peter-evans/create-pull-request@v7
110+
with:
111+
commit-message: "chore: regenerate SDK from spec ${{ env.SPEC_VERSION }}"
112+
branch: "regen/${{ env.SPEC_VERSION }}"
113+
title: "Regenerate SDK (${{ env.SPEC_VERSION }})"
114+
base: v3-dev
115+
body: >
116+
Automated regeneration for spec version
117+
`${{ env.SPEC_VERSION }}`.

0 commit comments

Comments
 (0)