Skip to content

Commit 57a68fb

Browse files
authored
ci: build Codex package archives in release workflow (#23582)
## Why Release CI already builds the Codex entrypoints before staging artifacts, and the package builder can now package those prebuilt binaries directly. The workflow should produce package-shaped sidecar archives from the same staged entrypoints that downstream distribution channels will eventually consume, without rebuilding `codex` or `codex-app-server` inside the packaging step. This intentionally does **not** publish the new package archives as GitHub Release assets yet. The archives are kept with workflow artifacts until npm, Homebrew, `install.sh`, winget, and related consumers are ready to switch over. ## What changed - Adds a `Build Codex package archive` step to `.github/workflows/rust-release.yml` after target artifacts are staged. - Runs `scripts/build_codex_package.py` for both release bundles: - `primary` builds `codex-package-${TARGET}.tar.gz` with `--variant codex`. - `app-server` builds `codex-app-server-package-${TARGET}.tar.gz` with `--variant codex-app-server`. - Passes `--entrypoint-bin target/${TARGET}/release/<entrypoint>` so packages contain the entrypoint already built by the workflow. - Deletes both package archive names before the final GitHub Release upload so they remain workflow artifacts only for now. ## Verification - Parsed `.github/workflows/rust-release.yml` with Ruby's YAML loader. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/23582). * #23596 * __->__ #23582
1 parent 343a740 commit 57a68fb

3 files changed

Lines changed: 157 additions & 0 deletions

File tree

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
usage() {
5+
cat <<'EOF'
6+
Usage: build-codex-package-archive.sh \
7+
--target <rust-target> \
8+
--bundle <primary|app-server> \
9+
--entrypoint-dir <dir> \
10+
--archive-dir <dir> \
11+
[--target-suffixed-entrypoint]
12+
EOF
13+
}
14+
15+
target=""
16+
bundle=""
17+
entrypoint_dir=""
18+
archive_dir=""
19+
target_suffixed_entrypoint="false"
20+
21+
while [[ $# -gt 0 ]]; do
22+
case "$1" in
23+
--target)
24+
target="${2:?--target requires a value}"
25+
shift 2
26+
;;
27+
--bundle)
28+
bundle="${2:?--bundle requires a value}"
29+
shift 2
30+
;;
31+
--entrypoint-dir)
32+
entrypoint_dir="${2:?--entrypoint-dir requires a value}"
33+
shift 2
34+
;;
35+
--archive-dir)
36+
archive_dir="${2:?--archive-dir requires a value}"
37+
shift 2
38+
;;
39+
--target-suffixed-entrypoint)
40+
target_suffixed_entrypoint="true"
41+
shift
42+
;;
43+
-h|--help)
44+
usage
45+
exit 0
46+
;;
47+
*)
48+
echo "Unexpected argument: $1" >&2
49+
usage >&2
50+
exit 1
51+
;;
52+
esac
53+
done
54+
55+
if [[ -z "$target" || -z "$bundle" || -z "$entrypoint_dir" || -z "$archive_dir" ]]; then
56+
usage >&2
57+
exit 1
58+
fi
59+
60+
case "$bundle" in
61+
primary)
62+
variant="codex"
63+
entrypoint="codex"
64+
archive_stem="codex-package"
65+
;;
66+
app-server)
67+
variant="codex-app-server"
68+
entrypoint="codex-app-server"
69+
archive_stem="codex-app-server-package"
70+
;;
71+
*)
72+
echo "No Codex package variant for bundle: $bundle" >&2
73+
exit 1
74+
;;
75+
esac
76+
77+
exe_suffix=""
78+
case "$target" in
79+
*windows*)
80+
exe_suffix=".exe"
81+
;;
82+
esac
83+
84+
entrypoint_name="$entrypoint"
85+
if [[ "$target_suffixed_entrypoint" == "true" ]]; then
86+
entrypoint_name="${entrypoint_name}-${target}"
87+
fi
88+
89+
repo_root="${GITHUB_WORKSPACE:-}"
90+
if [[ -z "$repo_root" ]]; then
91+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
92+
fi
93+
94+
if command -v python3 >/dev/null 2>&1; then
95+
python_bin="python3"
96+
else
97+
python_bin="python"
98+
fi
99+
100+
mkdir -p "$archive_dir"
101+
package_dir="${RUNNER_TEMP:-/tmp}/${archive_stem}-${target}"
102+
archive_path="${archive_dir}/${archive_stem}-${target}.tar.gz"
103+
rm -rf "$package_dir"
104+
105+
"$python_bin" "${repo_root}/scripts/build_codex_package.py" \
106+
--target "$target" \
107+
--variant "$variant" \
108+
--entrypoint-bin "${entrypoint_dir%/}/${entrypoint_name}${exe_suffix}" \
109+
--cargo-profile release \
110+
--package-dir "$package_dir" \
111+
--archive-output "$archive_path" \
112+
--force

.github/workflows/rust-release-windows.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ jobs:
220220
"$dest/${binary}-${{ matrix.target }}.exe"
221221
done
222222
223+
- name: Build Codex package archives
224+
shell: bash
225+
run: |
226+
set -euo pipefail
227+
for bundle in primary app-server; do
228+
bash "${GITHUB_WORKSPACE}/.github/scripts/build-codex-package-archive.sh" \
229+
--target "${{ matrix.target }}" \
230+
--bundle "$bundle" \
231+
--entrypoint-dir "target/${{ matrix.target }}/release" \
232+
--archive-dir "dist/${{ matrix.target }}"
233+
done
234+
223235
- name: Build Python runtime wheel
224236
shell: bash
225237
run: |

.github/workflows/rust-release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,20 @@ jobs:
519519
cp target/${{ matrix.target }}/release/codex-${{ matrix.target }}.dmg "$dest/codex-${{ matrix.target }}.dmg"
520520
fi
521521
522+
- name: Build Codex package archive
523+
if: ${{ runner.os != 'macOS' || env.SIGN_MACOS == 'true' }}
524+
shell: bash
525+
env:
526+
TARGET: ${{ matrix.target }}
527+
BUNDLE: ${{ matrix.bundle }}
528+
run: |
529+
set -euo pipefail
530+
bash "${GITHUB_WORKSPACE}/.github/scripts/build-codex-package-archive.sh" \
531+
--target "$TARGET" \
532+
--bundle "$BUNDLE" \
533+
--entrypoint-dir "target/${TARGET}/release" \
534+
--archive-dir "dist/${TARGET}"
535+
522536
- name: Build Python runtime wheel
523537
if: ${{ matrix.bundle == 'primary' && (runner.os != 'macOS' || env.SIGN_MACOS == 'true') }}
524538
shell: bash
@@ -819,6 +833,20 @@ jobs:
819833
--platform-tag "$platform_tag"
820834
"${RUNNER_TEMP}/python-runtime-build-venv/bin/python" -m build --wheel --outdir "$wheel_dir" "$stage_dir"
821835
836+
- name: Build Codex package archive
837+
shell: bash
838+
env:
839+
TARGET: ${{ matrix.target }}
840+
BUNDLE: ${{ matrix.bundle }}
841+
run: |
842+
set -euo pipefail
843+
bash "${GITHUB_WORKSPACE}/.github/scripts/build-codex-package-archive.sh" \
844+
--target "$TARGET" \
845+
--bundle "$BUNDLE" \
846+
--entrypoint-dir "dist/${TARGET}" \
847+
--archive-dir "dist/${TARGET}" \
848+
--target-suffixed-entrypoint
849+
822850
- name: Upload Python runtime wheel
823851
if: ${{ matrix.bundle == 'primary' }}
824852
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
@@ -1079,6 +1107,11 @@ jobs:
10791107
# If included in files: dist/**, release upload races on duplicate
10801108
# asset names and can fail with 404s.
10811109
find dist -type f -name 'cargo-timing.html' -delete
1110+
# Keep package-builder sidecar archives as workflow artifacts only
1111+
# until distribution channels are ready to consume them.
1112+
find dist -type f \
1113+
\( -name 'codex-package-*' -o -name 'codex-app-server-package-*' \) \
1114+
-delete
10821115
find dist -type d -empty -delete
10831116
10841117
ls -R dist/

0 commit comments

Comments
 (0)