|
| 1 | +# Fork-only release workflow. Builds static musl binaries of the fork and |
| 2 | +# publishes a GitHub release tagged with the full fork commit SHA, which is |
| 3 | +# how the Vogt engine installs the fork (WI-1142). |
| 4 | +# |
| 5 | +# New file with a fork-unique name on purpose: upstream workflow files are |
| 6 | +# never edited here, so rebasing onto upstream stays conflict-free. |
| 7 | +name: fork-release |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [fork/main] |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | +env: |
| 18 | + # aws-lc's jitter entropy path does not build on musl. |
| 19 | + AWS_LC_SYS_NO_JITTER_ENTROPY: "1" |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: ${{ matrix.target }} |
| 24 | + runs-on: ${{ matrix.runner }} |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + include: |
| 29 | + - target: x86_64-unknown-linux-musl |
| 30 | + runner: ubuntu-24.04 |
| 31 | + - target: aarch64-unknown-linux-musl |
| 32 | + runner: ubuntu-24.04-arm |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.0.1 |
| 35 | + with: |
| 36 | + persist-credentials: false |
| 37 | + |
| 38 | + # Reuses the upstream musl setup verbatim: zig 0.14.0 as the C toolchain, |
| 39 | + # then .github/scripts/install-musl-build-tools.sh (musl gcc linker, |
| 40 | + # libcap built for the target, OpenSSL). |
| 41 | + - name: Install Zig |
| 42 | + uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 |
| 43 | + with: |
| 44 | + version: "0.14.0" |
| 45 | + use-cache: false |
| 46 | + |
| 47 | + - name: Install musl build tools |
| 48 | + env: |
| 49 | + TARGET: ${{ matrix.target }} |
| 50 | + run: bash "${GITHUB_WORKSPACE}/.github/scripts/install-musl-build-tools.sh" |
| 51 | + |
| 52 | + - name: Set up Rust toolchain |
| 53 | + uses: dtolnay/rust-toolchain@e081816240890017053eacbb1bdf337761dc5582 # 1.95.0 |
| 54 | + with: |
| 55 | + targets: ${{ matrix.target }} |
| 56 | + |
| 57 | + # Downloads the Codex-built rusty_v8 prebuilts from the upstream release |
| 58 | + # and verifies them against the in-tree checksum manifest. |
| 59 | + - name: Configure rusty_v8 artifact overrides and verify checksums |
| 60 | + uses: ./.github/actions/setup-rusty-v8 |
| 61 | + with: |
| 62 | + target: ${{ matrix.target }} |
| 63 | + |
| 64 | + # bwrap is built and stripped first: linux-sandbox embeds |
| 65 | + # option_env!("CODEX_BWRAP_SHA256") and verifies the bundled bwrap |
| 66 | + # against it, so the digest must be exported before the codex build. |
| 67 | + - name: Build bwrap and export digest |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + set -euo pipefail |
| 71 | + target="${{ matrix.target }}" |
| 72 | + cargo build --target "$target" --release --bin bwrap |
| 73 | + bwrap_path="target/${target}/release/bwrap" |
| 74 | + strip --strip-debug --strip-unneeded "$bwrap_path" |
| 75 | + digest="$(sha256sum "$bwrap_path" | awk '{print $1}')" |
| 76 | + echo "CODEX_BWRAP_SHA256=${digest}" >> "$GITHUB_ENV" |
| 77 | +
|
| 78 | + # The workspace version is 0.0.0; stamp it as <upstream tag>+fork.<sha> |
| 79 | + # so `codex --version` reports the fork. Cargo bakes the version in via |
| 80 | + # CARGO_PKG_VERSION, which clap's `version` attribute prints. |
| 81 | + - name: Stamp fork version |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + set -euo pipefail |
| 85 | + # The fork base is the upstream stable tag; recorded in FORK.md and |
| 86 | + # advanced by the rebase procedure. `git describe` cannot be used: |
| 87 | + # upstream tags are not fetched into this checkout. |
| 88 | + upstream_version="0.162.0" |
| 89 | + stamp="${upstream_version}+fork.${GITHUB_SHA:0:9}" |
| 90 | + sed -i "0,/^version = \"0.0.0\"/s//version = \"${stamp}\"/" codex-rs/Cargo.toml |
| 91 | + grep -m1 '^version' codex-rs/Cargo.toml |
| 92 | +
|
| 93 | + - name: Build release binaries |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + set -euo pipefail |
| 97 | + target="${{ matrix.target }}" |
| 98 | + cargo build --target "$target" --release --bin codex --bin codex-code-mode-host |
| 99 | + for bin in codex codex-code-mode-host bwrap; do |
| 100 | + strip --strip-debug --strip-unneeded "target/${target}/release/${bin}" |
| 101 | + done |
| 102 | +
|
| 103 | + - name: Package |
| 104 | + shell: bash |
| 105 | + run: | |
| 106 | + set -euo pipefail |
| 107 | + target="${{ matrix.target }}" |
| 108 | + stage="dist/${target}" |
| 109 | + mkdir -p "$stage" |
| 110 | + for bin in codex codex-code-mode-host bwrap; do |
| 111 | + cp "target/${target}/release/${bin}" "$stage/${bin}" |
| 112 | + done |
| 113 | + (cd dist && sha256sum "${target}/codex" "${target}/codex-code-mode-host" "${target}/bwrap") > "dist/SHA256SUMS-${target}" |
| 114 | + tar -C dist -czf "dist/codex-${target}.tar.gz" "${target}" |
| 115 | +
|
| 116 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 117 | + with: |
| 118 | + name: ${{ matrix.target }} |
| 119 | + path: | |
| 120 | + dist/codex-${{ matrix.target }}.tar.gz |
| 121 | + dist/SHA256SUMS-${{ matrix.target }} |
| 122 | +
|
| 123 | + release: |
| 124 | + name: publish |
| 125 | + needs: build |
| 126 | + runs-on: ubuntu-24.04 |
| 127 | + steps: |
| 128 | + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 129 | + with: |
| 130 | + path: release |
| 131 | + merge-multiple: true |
| 132 | + |
| 133 | + - name: Assemble checksums |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + set -euo pipefail |
| 137 | + cat release/SHA256SUMS-* | sort > release/SHA256SUMS |
| 138 | + rm release/SHA256SUMS-* |
| 139 | +
|
| 140 | + # The release tag is the full fork commit SHA, so the Vogt engine can |
| 141 | + # install exactly the commit it pins. |
| 142 | + - name: Publish GitHub release |
| 143 | + env: |
| 144 | + GH_TOKEN: ${{ github.token }} |
| 145 | + shell: bash |
| 146 | + run: | |
| 147 | + set -euo pipefail |
| 148 | + if gh release view "$GITHUB_SHA" >/dev/null 2>&1; then |
| 149 | + echo "release ${GITHUB_SHA} already exists" |
| 150 | + exit 0 |
| 151 | + fi |
| 152 | + gh release create "$GITHUB_SHA" release/* \ |
| 153 | + --target "$GITHUB_SHA" \ |
| 154 | + --title "fork ${GITHUB_SHA:0:9}" \ |
| 155 | + --notes "Fork build of ${GITHUB_SHA}. Static musl binaries for x86_64 and aarch64; verify with SHA256SUMS." |
0 commit comments