Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/scripts/build-codex-package-archive.sh
Original file line number Diff line number Diff line change
@@ -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" \
--force
12 changes: 12 additions & 0 deletions .github/workflows/rust-release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 wheel
shell: bash
run: |
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/rust-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] This sidecar builder only runs in the main build job. promote_signed skips that job and uses stage-signed-macos, while Windows release artifacts are produced through rust-release-windows.yml, so those release paths never emit the package archives this PR is introducing. That leaves the workflow artifacts inconsistent across release modes/targets even though the PR is setting up package archives for future consumers. Could we mirror this archive step in the signed-promotion macOS path and the Windows release workflow, or factor the packaging invocation into a shared helper that all three paths call before artifact upload?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in the latest push. I factored the package-archive invocation into .github/scripts/build-codex-package-archive.sh, then wired it into all three release paths: the existing Linux/macOS build matrix, stage-signed-macos for promote_signed, and rust-release-windows.yml after Windows signing/staging. The signed macOS path packages from the target-suffixed signed files in dist/<target>, and Windows emits both primary and app-server package archives before artifact upload. Verified with Bash syntax checks, YAML parsing for both workflows, and a local signed-mac-style helper run that produced codex-package-aarch64-apple-darwin.tar.gz.

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 wheel
if: ${{ matrix.bundle == 'primary' && (runner.os != 'macOS' || env.SIGN_MACOS == 'true') }}
shell: bash
Expand Down Expand Up @@ -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 wheel
if: ${{ matrix.bundle == 'primary' }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
Expand Down Expand Up @@ -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-*' \) \
-delete
find dist -type d -empty -delete

ls -R dist/
Expand Down
Loading