name: python-sdk-build on: workflow_call: inputs: source_ref: description: "Source revision to build; defaults to the calling workflow revision." required: false type: string sdk_version: description: "Python SDK version to build." required: true type: string runtime_version: description: "Exact Python CLI runtime dependency for this SDK release." required: true type: string jobs: build-python-sdk: if: github.repository == 'openai/codex' name: build-python-sdk runs-on: ubuntu-latest permissions: contents: read steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.source_ref || github.sha }} persist-credentials: false # A retry can rebuild an older release. Use the tool pins from this workflow. - name: Checkout release build tools uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ github.workflow_sha }} path: release-tools sparse-checkout: .github/actions/setup-python-release-tools persist-credentials: false - name: Setup Python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: python-version: "3.12" - name: Set up Python release tools uses: ./release-tools/.github/actions/setup-python-release-tools with: group: sdk - name: Build Python SDK package shell: bash env: SDK_VERSION: ${{ inputs.sdk_version }} RUNTIME_VERSION: ${{ inputs.runtime_version }} run: | set -euo pipefail build_python="${RUNNER_TEMP}/python-sdk-build-venv/bin/python" "$build_python" sdk/python/scripts/update_sdk_artifacts.py \ stage-sdk "${RUNNER_TEMP}/openai-codex" \ --sdk-version "$SDK_VERSION" \ --codex-version "$RUNTIME_VERSION" uv build --offline --no-build-isolation --no-create-gitignore \ --force-pep517 --python "$build_python" \ --wheel \ --sdist \ --out-dir dist/python-sdk \ "${RUNNER_TEMP}/openai-codex" "$build_python" -m twine check --strict dist/python-sdk/* - name: Upload Python SDK package uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: name: python-sdk-package path: dist/python-sdk/* if-no-files-found: error