mirror of
https://github.com/openai/codex.git
synced 2026-10-23 18:08:45 +00:00
## Why Python release jobs installed build tools without a shared lockfile and allowed isolated builds to resolve additional dependencies. Release retries can also build older source revisions, so their tool pins need to come from the running workflow revision. ## What changed - Add a shared setup action with pinned `uv` and locked `sdk` and `runtime` dependency groups. Apply a seven-day dependency age cutoff, with a two-day exception for `certifi` CA trust updates. - Use the action for Python SDK and runtime packaging across Linux, macOS, and Windows. Build with `uv build --offline --no-build-isolation` using the prepared environments. - In the standalone Python build workflows, check out the release tools from `github.workflow_sha` separately from the requested source revision. GitOrigin-RevId: a9c0344930e5b9870ce9f7754a1fee1a9219305c
128 lines
4.6 KiB
YAML
128 lines
4.6 KiB
YAML
name: python-runtime-build
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
source_ref:
|
|
description: "Source revision to build; defaults to the calling workflow revision."
|
|
required: false
|
|
type: string
|
|
runtime_version:
|
|
description: "Runtime version to build, for example 0.136.0, 0.136.0a2, or 0.136.0a2.post1."
|
|
required: true
|
|
type: string
|
|
outputs:
|
|
python_version:
|
|
value: ${{ jobs.build-python-runtime.outputs.python_version }}
|
|
|
|
jobs:
|
|
build-python-runtime:
|
|
if: github.repository == 'openai/codex'
|
|
name: build-python-runtime
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
outputs:
|
|
python_version: ${{ steps.python_runtime.outputs.python_version }}
|
|
|
|
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: Validate and resolve Python runtime release
|
|
id: python_runtime
|
|
shell: bash
|
|
env:
|
|
REQUESTED_RUNTIME_VERSION: ${{ inputs.runtime_version }}
|
|
run: |
|
|
set -euo pipefail
|
|
python3 sdk/python/release_version.py \
|
|
"$REQUESTED_RUNTIME_VERSION" \
|
|
--github-output "$GITHUB_OUTPUT"
|
|
|
|
- name: Download Python runtime release artifacts
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PYTHON_RUNTIME_VERSION: ${{ steps.python_runtime.outputs.python_version }}
|
|
RELEASE_TAG: ${{ steps.python_runtime.outputs.release_tag }}
|
|
run: |
|
|
set -euo pipefail
|
|
mkdir -p dist/python-runtime dist/python-runtime-packages
|
|
gh release download "$RELEASE_TAG" \
|
|
--repo "${GITHUB_REPOSITORY}" \
|
|
--pattern "openai_codex_cli_bin-${PYTHON_RUNTIME_VERSION}-*.whl" \
|
|
--dir dist/python-runtime
|
|
gh release download "$RELEASE_TAG" \
|
|
--repo "${GITHUB_REPOSITORY}" \
|
|
--pattern "codex-package-*-unknown-linux-musl.tar.gz" \
|
|
--dir dist/python-runtime-packages
|
|
|
|
shopt -s nullglob
|
|
wheels=(dist/python-runtime/*.whl)
|
|
if [[ "${#wheels[@]}" -ne 6 ]]; then
|
|
echo "Expected 6 Python runtime wheels for ${PYTHON_RUNTIME_VERSION}, found ${#wheels[@]}."
|
|
exit 1
|
|
fi
|
|
packages=(dist/python-runtime-packages/*.tar.gz)
|
|
if [[ "${#packages[@]}" -ne 2 ]]; then
|
|
echo "Expected 2 Linux package archives for ${PYTHON_RUNTIME_VERSION}, found ${#packages[@]}."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Set up Python release tools
|
|
uses: ./release-tools/.github/actions/setup-python-release-tools
|
|
with:
|
|
group: runtime
|
|
|
|
- name: Build musllinux Python runtime wheels
|
|
env:
|
|
RELEASE_TAG: ${{ steps.python_runtime.outputs.release_tag }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
|
|
while read -r target platform_tag; do
|
|
stage_dir="${RUNNER_TEMP}/openai-codex-cli-bin-${target}-${platform_tag}"
|
|
python3 sdk/python/scripts/update_sdk_artifacts.py \
|
|
stage-runtime \
|
|
"$stage_dir" \
|
|
"dist/python-runtime-packages/codex-package-${target}.tar.gz" \
|
|
--codex-version "$RELEASE_TAG" \
|
|
--platform-tag "$platform_tag"
|
|
uv build --offline --no-build-isolation --no-create-gitignore \
|
|
--python "${RUNNER_TEMP}/python-runtime-build-venv" \
|
|
--wheel \
|
|
--out-dir dist/python-runtime \
|
|
"$stage_dir"
|
|
done <<'EOF'
|
|
aarch64-unknown-linux-musl musllinux_1_1_aarch64
|
|
x86_64-unknown-linux-musl musllinux_1_1_x86_64
|
|
EOF
|
|
|
|
shopt -s nullglob
|
|
wheels=(dist/python-runtime/*.whl)
|
|
if [[ "${#wheels[@]}" -ne 8 ]]; then
|
|
echo "Expected 8 Python runtime wheels, found ${#wheels[@]}."
|
|
exit 1
|
|
fi
|
|
ls -lh dist/python-runtime
|
|
|
|
- name: Upload Python runtime wheels
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
with:
|
|
name: python-runtime-wheels
|
|
path: dist/python-runtime/*
|
|
if-no-files-found: error
|