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
6 changes: 3 additions & 3 deletions .agents/skills/pwragent-release/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Use the repository's downstream pipeline. Read [the distribution contract](../..

- Verify the fork remote, `pwragent` source commit, working tree, recent CI results, existing remote tags, and existing GitHub releases. Preserve unrelated work. Investigate relevant CI failures before tagging, including failures that happen before compilation.
- The established naming is `pwragent-v<major.minor.patch>-pwragent.<N>`. For example, upstream `rust-v0.155.0-alpha.9` becomes downstream version `0.155.0-pwragent.1` and tag `pwragent-v0.155.0-pwragent.1`. Drop the upstream prerelease suffix; the downstream separator is `-pwragent.`, not `.pwragent.`. Choose an unused sequence number for the baseline and honor an explicitly requested version when the workflow supports it.
- The source can remain based on an upstream alpha tag. The tag-derived `CODEX_BUILD_VERSION` stamps the downstream version into packaged executables; do not change the Rust workspace version merely to duplicate that stamp.
- Keep `scripts/pwragent-release/upstream-version.txt` aligned with the intended numeric upstream baseline. It controls untagged development builds; tagged builds derive their version from the tag.
- The source can remain based on an upstream alpha tag. The tag-derived `CODEX_BUILD_VERSION` stamps the downstream version into `--version` output. Leave `codex-rs/Cargo.toml` at upstream's `0.0.0` placeholder in Git; the workflows stamp it at build time (see below).
- Keep `scripts/pwragent-release/upstream-version.txt` aligned with the intended numeric upstream baseline. Build jobs stamp it into the Cargo workspace version with `stamp-workspace-version.py`, so it becomes `CARGO_PKG_VERSION` and the backend `/models` `client_version`. A wrong baseline hides models. The tag version must start with `<upstream-version>-`, otherwise the build fails. Untagged development builds also derive their version from it.
- Check that Cargo's lockfile matches the workspace, using `cargo metadata --locked --filter-platform <host-triple> --format-version 1`. Do not discard required workspace-version updates as cosmetic churn. Follow AGENTS.md for dependency/lock changes, including `just bazel-lock-update`.
- Run `python3 scripts/pwragent-release/check-release-signing.py` and the manifest tests (`python3 -m unittest discover -s scripts/pwragent-release -p 'test_*.py'`). Reuse still-applicable build/test evidence from the sync; additional tests should address actual changes or unresolved concerns.
- Run `python3 scripts/pwragent-release/check-release-signing.py` and the release script tests (`python3 -m unittest discover -s scripts/pwragent-release -p 'test_*.py'`). Reuse still-applicable build/test evidence from the sync; additional tests should address actual changes or unresolved concerns.
- When checking local Code Mode binaries, rebuild helpers from the release source and run the host and deferred-reducer smoke scripts. Read each script's arguments. For V8 download failures, use the exact-version, checksum-verified assets configured by [setup-rusty-v8](../../../.github/actions/setup-rusty-v8/action.yml), following [the V8 README](../../../third_party/v8/README.md).

## Trigger publication
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/pwragent-macos-unsigned.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ jobs:
CODEX_BUILD_VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
# Upstream main keeps the workspace at 0.0.0. Stamp the real upstream
# version so CARGO_PKG_VERSION (and the backend client_version) is right.
python3 ../scripts/pwragent-release/stamp-workspace-version.py stamp \
--expect-release-version "$CODEX_BUILD_VERSION"
cargo build --locked --target "$TARGET" --release \
--bin codex \
--bin codex-app-server \
--bin codex-code-mode-host
python3 ../scripts/pwragent-release/stamp-workspace-version.py verify

- name: Save Cargo cache
if: always()
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/pwragent-release-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- ".github/workflows/pwragent-release*.yml"
- ".github/workflows/pwragent-macos-unsigned.yml"
- "docs/pwragent-distribution.md"
- "codex-rs/Cargo.toml"
- "scripts/pwragent-release/**"
push:
branches:
Expand All @@ -20,6 +21,7 @@ on:
- ".github/workflows/pwragent-release*.yml"
- ".github/workflows/pwragent-macos-unsigned.yml"
- "docs/pwragent-distribution.md"
- "codex-rs/Cargo.toml"
- "scripts/pwragent-release/**"

permissions:
Expand All @@ -42,8 +44,23 @@ jobs:
- name: Validate fail-closed signing workflow
run: python3 scripts/pwragent-release/check-release-signing.py

- name: Validate update manifest contract
run: python3 -m unittest scripts/pwragent-release/test_generate_update_manifest.py
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@d124f86f28ff42855784ff3319f48ac182c248f8 # 1.99.1

- name: Validate release script contracts
run: python3 -m unittest discover -s scripts/pwragent-release -p 'test_*.py'

# Release builds stamp the upstream version over the 0.0.0 placeholder.
# Prove that still works on this tree (e.g. after an upstream rebase
# changes the workspace layout) without waiting for a release build.
- name: Validate workspace version stamping
run: |
set -euo pipefail
python3 scripts/pwragent-release/stamp-workspace-version.py stamp
python3 scripts/pwragent-release/stamp-workspace-version.py verify
# Resolves against the index only; unlike `cargo metadata` it does not
# download every dependency's sources.
(cd codex-rs && cargo update --workspace --locked)

trusted-signing-preparation:
name: Prepare TrustedSigning client
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pwragent-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ jobs:
echo "::error::Resolved version is not SemVer: $version" >&2
exit 1
fi
# Fail before the build matrix starts if the tag drifted from the
# upstream baseline the build jobs stamp into Cargo.toml.
python3 scripts/pwragent-release/stamp-workspace-version.py \
check-release-version "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"

build:
Expand Down Expand Up @@ -186,6 +190,10 @@ jobs:
shell: bash
run: |
set -euo pipefail
# Upstream main keeps the workspace at 0.0.0. Stamp the real upstream
# version so CARGO_PKG_VERSION (and the backend client_version) is right.
python3 ../scripts/pwragent-release/stamp-workspace-version.py stamp \
--expect-release-version "$CODEX_VERSION"
export CODEX_BUILD_VERSION="$CODEX_VERSION"
# Avoid overlapping memory-heavy CLI and app-server compilation on
# hosted macOS and ARM runners; retain the normal release profile.
Expand All @@ -196,6 +204,7 @@ jobs:
--bin codex \
--bin codex-app-server \
--bin codex-code-mode-host
python3 ../scripts/pwragent-release/stamp-workspace-version.py verify

- name: Save Cargo cache
if: always()
Expand Down Expand Up @@ -543,13 +552,17 @@ jobs:
run: |
set -euo pipefail
export LIBSQLITE3_FLAGS=SQLITE_DISABLE_INTRINSIC
# See the Unix build: stamp the real upstream workspace version.
python ../scripts/pwragent-release/stamp-workspace-version.py stamp \
--expect-release-version "$CODEX_VERSION"
export CODEX_BUILD_VERSION="$CODEX_VERSION"
cargo build --target x86_64-pc-windows-msvc --release \
--bin codex \
--bin codex-app-server \
--bin codex-code-mode-host \
--bin codex-windows-sandbox-setup \
--bin codex-command-runner
python ../scripts/pwragent-release/stamp-workspace-version.py verify

- name: Save Cargo cache
if: always()
Expand Down
18 changes: 18 additions & 0 deletions docs/pwragent-distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,24 @@ binaries. Development artifacts use the reviewed upstream compatibility baseline
each staged binary with `--version` before packaging, so `PWRAGENT-BUILD.txt`
and the executable identity cannot silently diverge.

`CODEX_BUILD_VERSION` only reaches `--version` and a few user-agent strings.
Everything else reads `CARGO_PKG_VERSION`, including the `client_version` the
models manager sends to the backend `/models` endpoint, which hides models
whose minimum client version is higher. Upstream `main` keeps
`codex-rs/Cargo.toml` at the `0.0.0` placeholder and writes the real version
only on its release tags, so every build job runs
`scripts/pwragent-release/stamp-workspace-version.py stamp` before `cargo
build`. That writes the plain upstream version from `upstream-version.txt` into
`[workspace.package]` and the matching `Cargo.lock` entries, so `--locked`
builds still work. The workspace version is never committed. The metadata job
first requires the downstream version to start with that upstream version, so a
tag that drifted from the baseline fails before any build. After the build,
`stamp-workspace-version.py verify` fails the job unless every crate that
inherits the workspace version has that version in both `Cargo.toml` and
`Cargo.lock`.
`pwragent-release-check.yml` runs the same stamp-and-verify on every relevant
change, without a build.

### Manually (`workflow_dispatch`)

A manual run builds every platform but enters no signing environment. It emits
Expand Down
28 changes: 28 additions & 0 deletions scripts/pwragent-release/check-release-signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,34 @@ def job(workflow: str, name: str) -> str:
for binary in UNIX_BINARIES:
require(build, f"--bin {binary}", "build")

# Upstream main keeps codex-rs/Cargo.toml at version 0.0.0, and CARGO_PKG_VERSION
# is what the backend /models request sends as client_version. Every shipped or
# validated build must stamp the upstream version before compiling and verify
# it after, because the --version checks only see CODEX_BUILD_VERSION.
STAMP_SCRIPT = "../scripts/pwragent-release/stamp-workspace-version.py"


def require_workspace_version_stamp(section: str, scope: str, python: str) -> None:
stamp_command = f"{python} {STAMP_SCRIPT} stamp"
verify_command = f"{python} {STAMP_SCRIPT} verify"
require(section, stamp_command, scope)
require(section, "--expect-release-version", scope)
require(section, verify_command, scope)
build_at = section.find("cargo build")
if not section.find(stamp_command) < build_at < section.find(verify_command):
fail(f"{scope} must stamp the workspace version before cargo build and verify it after")


require_workspace_version_stamp(build, "build", "python3")
require_workspace_version_stamp(windows_prepare, "windows-prepare", "python")
require_workspace_version_stamp(unsigned_workflow, "unsigned macOS workflow", "python3")
for fragment in (
"scripts/pwragent-release/stamp-workspace-version.py stamp",
"scripts/pwragent-release/stamp-workspace-version.py verify",
"discover -s scripts/pwragent-release -p 'test_*.py'",
):
require(check_workflow, fragment, "release signing check workflow")

for fragment in (
"scripts/pwragent-release/prepare-trusted-signing.ps1",
"-OutputRoot signing-tools",
Expand Down
Loading