Lightweight coding agent that runs in your terminal
Rust
ci: build Codex package archives in release workflow (#23582)
Michael Bolin57a68fb9e3a3
diff --git a/.github/scripts/build-codex-package-archive.sh b/.github/scripts/build-codex-package-archive.shnew file mode 100644index 0000000000..90eae12ef0--- /dev/null+++ b/.github/scripts/build-codex-package-archive.sh@@ -0,0 +1,112 @@+#!/usr/bin/env bash+set -euo pipefail++usage() {+ cat <<'EOF'+Usage: build-codex-package-archive.sh \+ --target <rust-target> \+ --bundle <primary|app-server> \+ --entrypoint-dir <dir> \+ --archive-dir <dir> \+ [--target-suffixed-entrypoint]+EOF+}++target=""+bundle=""+entrypoint_dir=""+archive_dir=""+target_suffixed_entrypoint="false"++while [[ $# -gt 0 ]]; do+ case "$1" in+ --target)+ target="${2:?--target requires a value}"+ shift 2+ ;;+ --bundle)+ bundle="${2:?--bundle requires a value}"+ shift 2+ ;;+ --entrypoint-dir)+ entrypoint_dir="${2:?--entrypoint-dir requires a value}"+ shift 2+ ;;+ --archive-dir)+ archive_dir="${2:?--archive-dir requires a value}"+ shift 2+ ;;+ --target-suffixed-entrypoint)+ target_suffixed_entrypoint="true"+ shift+ ;;+ -h|--help)+ usage+ exit 0+ ;;+ *)+ echo "Unexpected argument: $1" >&2+ usage >&2+ exit 1+ ;;+ esac+done++if [[ -z "$target" || -z "$bundle" || -z "$entrypoint_dir" || -z "$archive_dir" ]]; then+ usage >&2+ exit 1+fi++case "$bundle" in+ primary)+ variant="codex"+ entrypoint="codex"+ archive_stem="codex-package"+ ;;+ app-server)+ variant="codex-app-server"+ entrypoint="codex-app-server"+ archive_stem="codex-app-server-package"+ ;;+ *)+ echo "No Codex package variant for bundle: $bundle" >&2+ exit 1+ ;;+esac++exe_suffix=""+case "$target" in+ *windows*)+ exe_suffix=".exe"+ ;;+esac++entrypoint_name="$entrypoint"+if [[ "$target_suffixed_entrypoint" == "true" ]]; then+ entrypoint_name="${entrypoint_name}-${target}"+fi++repo_root="${GITHUB_WORKSPACE:-}"+if [[ -z "$repo_root" ]]; then+ repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"+fi++if command -v python3 >/dev/null 2>&1; then+ python_bin="python3"+else+ python_bin="python"+fi++mkdir -p "$archive_dir"+package_dir="${RUNNER_TEMP:-/tmp}/${archive_stem}-${target}"+archive_path="${archive_dir}/${archive_stem}-${target}.tar.gz"+rm -rf "$package_dir"++"$python_bin" "${repo_root}/scripts/build_codex_package.py" \+ --target "$target" \+ --variant "$variant" \+ --entrypoint-bin "${entrypoint_dir%/}/${entrypoint_name}${exe_suffix}" \+ --cargo-profile release \+ --package-dir "$package_dir" \+ --archive-output "$archive_path" \+ --forcediff --git a/.github/workflows/rust-release-windows.yml b/.github/workflows/rust-release-windows.ymlindex 8a1b6030a8..ac28b7855a 100644--- a/.github/workflows/rust-release-windows.yml+++ b/.github/workflows/rust-release-windows.yml@@ -220,6 +220,18 @@ jobs:"$dest/${binary}-${{ matrix.target }}.exe"done+ - name: Build Codex package archives+ shell: bash+ run: |+ set -euo pipefail+ for bundle in primary app-server; do+ bash "${GITHUB_WORKSPACE}/.github/scripts/build-codex-package-archive.sh" \+ --target "${{ matrix.target }}" \+ --bundle "$bundle" \+ --entrypoint-dir "target/${{ matrix.target }}/release" \+ --archive-dir "dist/${{ matrix.target }}"+ done+- name: Build Python runtime wheelshell: bashrun: |diff --git a/.github/workflows/rust-release.yml b/.github/workflows/rust-release.ymlindex 50953506d3..c55337ecfe 100644--- a/.github/workflows/rust-release.yml+++ b/.github/workflows/rust-release.yml@@ -519,6 +519,20 @@ jobs:cp target/${{ matrix.target }}/release/codex-${{ matrix.target }}.dmg "$dest/codex-${{ matrix.target }}.dmg"fi+ - name: Build Codex package archive+ if: ${{ runner.os != 'macOS' || env.SIGN_MACOS == 'true' }}+ shell: bash+ env:+ TARGET: ${{ matrix.target }}+ BUNDLE: ${{ matrix.bundle }}+ run: |+ set -euo pipefail+ bash "${GITHUB_WORKSPACE}/.github/scripts/build-codex-package-archive.sh" \+ --target "$TARGET" \+ --bundle "$BUNDLE" \+ --entrypoint-dir "target/${TARGET}/release" \+ --archive-dir "dist/${TARGET}"+- name: Build Python runtime wheelif: ${{ matrix.bundle == 'primary' && (runner.os != 'macOS' || env.SIGN_MACOS == 'true') }}shell: bash@@ -819,6 +833,20 @@ jobs:--platform-tag "$platform_tag""${RUNNER_TEMP}/python-runtime-build-venv/bin/python" -m build --wheel --outdir "$wheel_dir" "$stage_dir"+ - name: Build Codex package archive+ shell: bash+ env:+ TARGET: ${{ matrix.target }}+ BUNDLE: ${{ matrix.bundle }}+ run: |+ set -euo pipefail+ bash "${GITHUB_WORKSPACE}/.github/scripts/build-codex-package-archive.sh" \+ --target "$TARGET" \+ --bundle "$BUNDLE" \+ --entrypoint-dir "dist/${TARGET}" \+ --archive-dir "dist/${TARGET}" \+ --target-suffixed-entrypoint+- name: Upload Python runtime wheelif: ${{ matrix.bundle == 'primary' }}uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0@@ -1079,6 +1107,11 @@ jobs:# If included in files: dist/**, release upload races on duplicate# asset names and can fail with 404s.find dist -type f -name 'cargo-timing.html' -delete+ # Keep package-builder sidecar archives as workflow artifacts only+ # until distribution channels are ready to consume them.+ find dist -type f \+ \( -name 'codex-package-*' -o -name 'codex-app-server-package-*' \) \+ -deletefind dist -type d -empty -deletels -R dist/