Skip to content

Commit e697962

Browse files
committed
fix(ci): include ogx-open-client in unified release pipeline
ogx-open-client was built and published ia a separate workflow, publish-openapi-sdk.yml, with no version coupling to the main ogx release. ogx-open-client version was taken from the fallback version of ogx, so it was always ended with `devX`. This commit adds ogx-open-client to the pypi.yml build/test/publish matrix so every ogx release automatically publishes a same-version client SDK. Fixes the standalone publish-openapi-sdk.yml to also derive its version from the trigger tag or an explicit input. To do the above it changes the version assignment in Makefile. Signed-off-by: E Geiger <egeiger@redhat.com>
1 parent 8ec83e0 commit e697962

3 files changed

Lines changed: 117 additions & 15 deletions

File tree

.github/workflows/publish-openapi-sdk.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ on:
1313
options:
1414
- testpypi
1515
- pypi
16+
version:
17+
description: 'Version override (e.g., "1.2.0"). Leave empty to auto-detect from tag or fallback_version.'
18+
required: false
19+
type: string
1620
dry_run:
1721
description: 'Dry run (build only, no publish)'
1822
type: boolean
@@ -29,7 +33,37 @@ permissions:
2933
contents: read
3034

3135
jobs:
36+
compute-version:
37+
name: Compute version
38+
runs-on: ubuntu-latest
39+
outputs:
40+
version: ${{ steps.version.outputs.version }}
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
44+
45+
- name: Compute SDK version
46+
id: version
47+
run: |
48+
if [ -n "${{ inputs.version }}" ]; then
49+
# Explicit override from workflow_dispatch
50+
VERSION="${{ inputs.version }}"
51+
elif [[ "$GITHUB_REF" == refs/tags/openapi-sdk-v* ]]; then
52+
# Extract version from tag: openapi-sdk-v1.2.0 -> 1.2.0
53+
VERSION="${GITHUB_REF#refs/tags/openapi-sdk-v}"
54+
else
55+
# Fall back to fallback_version from pyproject.toml
56+
VERSION=$(python3 -c "
57+
import tomllib, pathlib
58+
p = tomllib.loads(pathlib.Path('pyproject.toml').read_text())
59+
print(p.get('tool', {}).get('setuptools_scm', {}).get('fallback_version', '0.0.0.dev0'))
60+
")
61+
fi
62+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
63+
echo "Computed version: ${VERSION}"
64+
3265
build-sdk:
66+
needs: compute-version
3367
runs-on: ubuntu-latest
3468

3569
steps:
@@ -60,14 +94,15 @@ jobs:
6094
echo "=== OpenAPI Generator version ==="
6195
openapi-generator-cli version
6296
63-
echo "=== SDK version from pyproject.toml ==="
64-
make version
97+
echo "=== SDK version ==="
98+
echo "${{ needs.compute-version.outputs.version }}"
6599
66100
- name: Generate OpenAPI SDK
67101
working-directory: client-sdks/openapi
68102
run: |
69-
echo "Generating SDK with OPEN=1 (ogx_open_client)..."
70-
make sdk OPEN=1
103+
VERSION="${{ needs.compute-version.outputs.version }}"
104+
echo "Generating SDK with OPEN=1 (ogx_open_client) at version ${VERSION}..."
105+
make sdk OPEN=1 VERSION="${VERSION}"
71106
72107
- name: Verify SDK generation
73108
working-directory: client-sdks/openapi

.github/workflows/pypi.yml

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ jobs:
225225
path: .
226226
type: local
227227
registry: pypi
228+
# OpenAPI-generated SDK (built from spec in this repo)
229+
- package: ogx-open-client
230+
path: client-sdks/openapi
231+
type: openapi-sdk
232+
registry: pypi
228233
# External packages (client SDKs from other repos)
229234
- package: ogx-client-python
230235
repo: ogx-ai/ogx-client-python
@@ -246,7 +251,7 @@ jobs:
246251
247252
if [ "$PACKAGES" == "all" ]; then
248253
echo "skip=false" >> "$GITHUB_OUTPUT"
249-
elif [ "$PACKAGES" == "ogx-only" ] && [ "$TYPE" == "local" ]; then
254+
elif [ "$PACKAGES" == "ogx-only" ] && { [ "$TYPE" == "local" ] || [ "$TYPE" == "openapi-sdk" ]; }; then
250255
echo "skip=false" >> "$GITHUB_OUTPUT"
251256
elif [ "$PACKAGES" == "clients-only" ] && [ "$TYPE" == "external" ]; then
252257
echo "skip=false" >> "$GITHUB_OUTPUT"
@@ -257,13 +262,13 @@ jobs:
257262
258263
# === LOCAL PACKAGE STEPS ===
259264
- name: Checkout local repo
260-
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'local'
265+
if: steps.should-build.outputs.skip != 'true' && (matrix.type == 'local' || matrix.type == 'openapi-sdk')
261266
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
262267
with:
263268
fetch-depth: 0 # for setuptools-scm
264269

265270
- name: Install dependent PRs if needed
266-
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'local'
271+
if: steps.should-build.outputs.skip != 'true' && (matrix.type == 'local' || matrix.type == 'openapi-sdk')
267272
uses: depends-on/depends-on-action@826c144163ac67bf08347590a5f81afd45da63ca # main
268273
with:
269274
token: ${{ secrets.GITHUB_TOKEN }}
@@ -350,6 +355,48 @@ jobs:
350355
env:
351356
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.compute-version.outputs.version }}
352357

358+
# === OPENAPI SDK BUILD (ogx-open-client) ===
359+
- name: Set up Java (openapi-sdk)
360+
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'openapi-sdk'
361+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
362+
with:
363+
distribution: 'temurin'
364+
java-version: '11'
365+
366+
- name: Set up Node.js (openapi-sdk)
367+
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'openapi-sdk'
368+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
369+
with:
370+
node-version: '20'
371+
372+
- name: Install openapi-generator-cli (openapi-sdk)
373+
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'openapi-sdk'
374+
run: npm install -g @openapitools/openapi-generator-cli
375+
376+
- name: Generate and build OpenAPI SDK
377+
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'openapi-sdk'
378+
working-directory: ${{ matrix.path }}
379+
run: |
380+
VERSION="${{ needs.compute-version.outputs.version }}"
381+
echo "Generating SDK with OPEN=1 (ogx_open_client) at version ${VERSION}..."
382+
make sdk OPEN=1 VERSION="${VERSION}"
383+
384+
cd sdks/python
385+
echo "Building Python package..."
386+
uv build --out-dir ../../dist --no-build-isolation
387+
388+
- name: Verify OpenAPI SDK generation
389+
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'openapi-sdk'
390+
working-directory: ${{ matrix.path }}
391+
run: |
392+
PY_FILE_COUNT=$(find sdks/python -name "*.py" | wc -l)
393+
echo "Generated Python files: $PY_FILE_COUNT"
394+
if [ "$PY_FILE_COUNT" -le 10 ]; then
395+
echo "::error::Too few Python files generated (expected > 10, got $PY_FILE_COUNT)"
396+
exit 1
397+
fi
398+
echo "SDK generated successfully"
399+
353400
# === EXTERNAL PYTHON PACKAGE BUILD ===
354401
- name: Check and bump version if exists on PyPI
355402
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'external' && matrix.registry == 'pypi'
@@ -525,15 +572,15 @@ jobs:
525572
run: uv pip install --system twine check-wheel-contents
526573

527574
- name: Check wheel contents (local)
528-
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'local' && matrix.registry == 'pypi'
575+
if: steps.should-build.outputs.skip != 'true' && (matrix.type == 'local' || matrix.type == 'openapi-sdk') && matrix.registry == 'pypi'
529576
run: check-wheel-contents --ignore W002,W004 ${{ matrix.path }}/dist/*.whl
530577

531578
- name: Check wheel contents (external)
532579
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'external' && matrix.registry == 'pypi'
533580
run: check-wheel-contents --ignore W002,W004 external-repo/dist/*.whl
534581

535582
- name: Validate package with twine (local)
536-
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'local' && matrix.registry == 'pypi'
583+
if: steps.should-build.outputs.skip != 'true' && (matrix.type == 'local' || matrix.type == 'openapi-sdk') && matrix.registry == 'pypi'
537584
run: twine check ${{ matrix.path }}/dist/*
538585

539586
- name: Validate package with twine (external)
@@ -542,7 +589,7 @@ jobs:
542589

543590
# === LIST AND UPLOAD ARTIFACTS ===
544591
- name: List dist contents (local)
545-
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'local'
592+
if: steps.should-build.outputs.skip != 'true' && (matrix.type == 'local' || matrix.type == 'openapi-sdk')
546593
run: ls -la ${{ matrix.path }}/dist/
547594

548595
- name: List dist contents (external Python)
@@ -559,7 +606,7 @@ jobs:
559606
ls -la dist/
560607
561608
- name: Upload artifacts (local)
562-
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'local'
609+
if: steps.should-build.outputs.skip != 'true' && (matrix.type == 'local' || matrix.type == 'openapi-sdk')
563610
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
564611
with:
565612
name: Packages-${{ matrix.package }}
@@ -627,6 +674,14 @@ jobs:
627674
path: dist-client-ts
628675
continue-on-error: true
629676

677+
- name: Download ogx-open-client artifacts
678+
id: download-open-client
679+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
680+
with:
681+
name: Packages-ogx-open-client
682+
path: dist-open-client
683+
continue-on-error: true
684+
630685
- name: Create venv and install Python packages
631686
run: |
632687
uv venv .venv
@@ -648,6 +703,11 @@ jobs:
648703
uv pip install dist-stack/*.whl
649704
fi
650705
706+
if [ -d "dist-open-client" ] && ls dist-open-client/*.whl 1>/dev/null 2>&1; then
707+
echo "Installing ogx-open-client..."
708+
uv pip install dist-open-client/*.whl
709+
fi
710+
651711
- name: List Wheel Contents (ogx-api)
652712
if: steps.download-api.outcome == 'success'
653713
run: |
@@ -681,6 +741,10 @@ jobs:
681741
python -c "import ogx_client; print(f'ogx_client imported successfully from {ogx_client.__file__}')"
682742
fi
683743
744+
if [ -d "dist-open-client" ] && ls dist-open-client/*.whl 1>/dev/null 2>&1; then
745+
python -c "import ogx_open_client; print(f'ogx_open_client imported successfully from {ogx_open_client.__file__}')"
746+
fi
747+
684748
- name: Verify TypeScript package
685749
if: steps.download-client-ts.outcome == 'success'
686750
run: |
@@ -700,7 +764,7 @@ jobs:
700764
fi
701765
702766
# Publish packages to PyPI/npm
703-
# Order: ogx-client-python, ogx-client-typescript, ogx-api, ogx
767+
# Order: ogx-client-python, ogx-client-typescript, ogx-open-client, ogx-api, ogx
704768
publish-packages:
705769
name: Publish ${{ matrix.package }}
706770
if: |
@@ -727,6 +791,9 @@ jobs:
727791
- package: ogx-client-typescript
728792
registry: npm
729793
type: external
794+
- package: ogx-open-client
795+
registry: pypi
796+
type: openapi-sdk
730797
- package: ogx-api
731798
registry: pypi
732799
type: local
@@ -745,7 +812,7 @@ jobs:
745812
746813
if [ "$PACKAGES" == "all" ]; then
747814
echo "skip=false" >> "$GITHUB_OUTPUT"
748-
elif [ "$PACKAGES" == "ogx-only" ] && [ "$TYPE" == "local" ]; then
815+
elif [ "$PACKAGES" == "ogx-only" ] && { [ "$TYPE" == "local" ] || [ "$TYPE" == "openapi-sdk" ]; }; then
749816
echo "skip=false" >> "$GITHUB_OUTPUT"
750817
elif [ "$PACKAGES" == "clients-only" ] && [ "$TYPE" == "external" ]; then
751818
echo "skip=false" >> "$GITHUB_OUTPUT"

client-sdks/openapi/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ PROCESSED_SPEC := openapi-hierarchical.yml
3333
HIERARCHY_FILE := api-hierarchy.yml
3434
SDK_OUTPUT_DIR := sdks/python
3535

36-
# Extract version from root pyproject.toml
37-
VERSION := $(shell grep 'fallback_version' ../../pyproject.toml | cut -d'"' -f2)
36+
# Extract version from root pyproject.toml; override with make VERSION=X.Y.Z
37+
VERSION ?= $(shell grep 'fallback_version' ../../pyproject.toml | cut -d'"' -f2)
3838

3939
.PHONY: all sdk openapi hierarchy clean help version check-generator generate-config
4040

0 commit comments

Comments
 (0)