Update release workflow for Rust build process

This commit is contained in:
James Peter
2025-08-24 16:04:31 +10:00
committed by GitHub
parent 0b1d2b458b
commit 64dda2dedf
+35 -24
View File
@@ -58,7 +58,7 @@ jobs:
NEW_VERSION=$CURRENT_VERSION NEW_VERSION=$CURRENT_VERSION
fi fi
echo "Build version: $NEW_VERSION" echo "Version for this build: $NEW_VERSION"
echo "version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" echo "version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
build-binaries: build-binaries:
@@ -102,19 +102,20 @@ jobs:
with: with:
targets: ${{ matrix.target }} targets: ${{ matrix.target }}
# Cache registries + git only (no target/), to avoid overlapping with sccache # ⚡ Cache target/ + registries + (opt-in) workspace crates to skip linking when unchanged
- name: Cache Cargo registries and git - name: Setup Rust Cache (target + registries)
uses: actions/cache@v4 uses: Swatinem/rust-cache@v2
with: with:
path: | # bump prefix to invalidate caches if we change layout/flags
~/.cargo/registry/index prefix-key: v4-rust
~/.cargo/registry/cache # stable namespace per toolchain+target
~/.cargo/git shared-key: codex-${{ matrix.target }}-rust-1.89-target
key: cargo-${{ runner.os }}-${{ matrix.target }}-rust-1.89-${{ hashFiles('**/Cargo.lock') }} # cache the workspace target dir
restore-keys: | workspaces: |
cargo-${{ runner.os }}-${{ matrix.target }}-rust-1.89- codex-rs -> target
cargo-${{ runner.os }}-${{ matrix.target }}- cache-targets: true
cargo-${{ runner.os }}- cache-workspace-crates: true
cache-on-failure: true
# Stable sccache namespace per target+toolchain (bump suffix to roll caches intentionally) # Stable sccache namespace per target+toolchain (bump suffix to roll caches intentionally)
- name: Configure sccache cache keys - name: Configure sccache cache keys
@@ -122,14 +123,14 @@ jobs:
run: | run: |
echo "SCCACHE_GHA_VERSION=${{ matrix.target }}-rust-1.89-v4" >> "$GITHUB_ENV" echo "SCCACHE_GHA_VERSION=${{ matrix.target }}-rust-1.89-v4" >> "$GITHUB_ENV"
# Official sccache action; it handles installation & GHAC backend # sccache manages GH Actions Cache backend; no manual restarts/creds
- name: Setup sccache (GHA backend) - name: Setup sccache (GHA backend)
uses: mozilla-actions/[email protected] uses: mozilla-actions/[email protected]
with: with:
version: v0.10.0 version: v0.10.0
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
# Enable sccache via env (per action docs). Do NOT restart the server manually. # Enable sccache via env (per action docs)
- name: Enable sccache - name: Enable sccache
shell: bash shell: bash
run: | run: |
@@ -151,11 +152,10 @@ jobs:
sudo apt-get update sudo apt-get update
sudo apt-get install -y musl-tools pkg-config sudo apt-get install -y musl-tools pkg-config
# NEW: prefetch deps online so the subsequent --frozen build can run offline. # Prefetch deps (git + registry) so the subsequent --frozen build works offline
- name: Prefetch dependencies (git + registry) - name: Prefetch dependencies (git + registry)
working-directory: codex-rs working-directory: codex-rs
env: env:
# Work around occasional libgit2 issues on macOS: fetch using the git CLI.
CARGO_NET_GIT_FETCH_WITH_CLI: "true" CARGO_NET_GIT_FETCH_WITH_CLI: "true"
run: cargo fetch --locked run: cargo fetch --locked
@@ -165,20 +165,23 @@ jobs:
run: | run: |
echo "CODE_VERSION=${{ needs.determine-version.outputs.version }}" >> "$GITHUB_ENV" echo "CODE_VERSION=${{ needs.determine-version.outputs.version }}" >> "$GITHUB_ENV"
- name: Build binaries - name: Build binaries (with timings)
shell: bash shell: bash
env: env:
RUSTFLAGS: ${{ contains(matrix.os, 'ubuntu') && '-Awarnings -C link-arg=-fuse-ld=mold' || '-Awarnings' }} # keep mold on Linux; trim debug for faster links; avoid warnings noise
RUSTFLAGS: ${{ contains(matrix.os, 'ubuntu') && '-Awarnings -C link-arg=-fuse-ld=mold -C debuginfo=0' || '-Awarnings -C debuginfo=0' }}
CARGO_INCREMENTAL: "0" CARGO_INCREMENTAL: "0"
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"
run: | run: |
cd codex-rs cd codex-rs
# Reproducible, cache-friendly build; now safe to be offline # Reproducible, cache-friendly build; --timings writes HTML to target/cargo-timings/
cargo build --release --frozen --locked --target ${{ matrix.target }} --bin code --bin code-tui --bin code-exec cargo build --release --frozen --locked --timings --target ${{ matrix.target }} --bin code --bin code-tui --bin code-exec
- name: sccache stats (optional) - name: sccache stats (human + json)
shell: bash shell: bash
run: sccache --show-stats || true run: |
sccache --show-stats || true
sccache --show-stats --stats-format=json || true
- name: Prepare artifacts - name: Prepare artifacts
shell: bash shell: bash
@@ -194,12 +197,20 @@ jobs:
cp codex-rs/target/${{ matrix.target }}/release/code-exec artifacts/code-exec-${{ matrix.target }} cp codex-rs/target/${{ matrix.target }}/release/code-exec artifacts/code-exec-${{ matrix.target }}
fi fi
- name: Upload artifacts - name: Upload binaries
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: binaries-${{ matrix.target }} name: binaries-${{ matrix.target }}
path: artifacts/ path: artifacts/
# Upload Cargo timing reports for this target (HTML files)
- name: Upload cargo timings
uses: actions/upload-artifact@v4
with:
name: cargo-timings-${{ matrix.target }}
path: codex-rs/target/cargo-timings/*.html
if-no-files-found: ignore
release: release:
name: Publish to npm name: Publish to npm
needs: [determine-version, build-binaries] needs: [determine-version, build-binaries]