|
| 1 | +# Release workflow for BrowserOS Codex binaries. |
| 2 | +# Builds all distributions without signing. |
| 3 | +# To release, run: |
| 4 | +# ``` |
| 5 | +# git tag -a browseros-v0.1.0 -m "Release 0.1.0" |
| 6 | +# git push origin browseros-v0.1.0 |
| 7 | +# ``` |
| 8 | + |
| 9 | +name: release-browseros |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + tags: |
| 14 | + - "browseros-v*.*.*" |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + tag-check: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v5 |
| 25 | + |
| 26 | + - name: Validate tag matches Cargo.toml version |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + set -euo pipefail |
| 30 | + echo "::group::Tag validation" |
| 31 | +
|
| 32 | + # 1. Must be a tag and match the regex |
| 33 | + [[ "${GITHUB_REF_TYPE}" == "tag" ]] \ |
| 34 | + || { echo "❌ Not a tag push"; exit 1; } |
| 35 | + [[ "${GITHUB_REF_NAME}" =~ ^browseros-v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta)(\.[0-9]+)?)?$ ]] \ |
| 36 | + || { echo "❌ Tag '${GITHUB_REF_NAME}' doesn't match expected format"; exit 1; } |
| 37 | +
|
| 38 | + # 2. Extract versions |
| 39 | + tag_ver="${GITHUB_REF_NAME#browseros-v}" |
| 40 | + cargo_ver="$(grep -m1 '^version' codex-rs/Cargo.toml \ |
| 41 | + | sed -E 's/version *= *"([^"]+)".*/\1/')" |
| 42 | +
|
| 43 | + # 3. Compare |
| 44 | + [[ "${tag_ver}" == "${cargo_ver}" ]] \ |
| 45 | + || { echo "❌ Tag ${tag_ver} ≠ Cargo.toml ${cargo_ver}"; exit 1; } |
| 46 | +
|
| 47 | + echo "✅ Tag and Cargo.toml agree (${tag_ver})" |
| 48 | + echo "::endgroup::" |
| 49 | +
|
| 50 | + build: |
| 51 | + needs: tag-check |
| 52 | + name: Build - ${{ matrix.runner }} - ${{ matrix.target }} |
| 53 | + runs-on: ${{ matrix.runner }} |
| 54 | + timeout-minutes: 30 |
| 55 | + defaults: |
| 56 | + run: |
| 57 | + working-directory: codex-rs |
| 58 | + |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: |
| 62 | + include: |
| 63 | + - runner: macos-15-xlarge |
| 64 | + target: aarch64-apple-darwin |
| 65 | + - runner: macos-15-xlarge |
| 66 | + target: x86_64-apple-darwin |
| 67 | + - runner: ubuntu-24.04 |
| 68 | + target: x86_64-unknown-linux-musl |
| 69 | + - runner: ubuntu-24.04 |
| 70 | + target: x86_64-unknown-linux-gnu |
| 71 | + - runner: ubuntu-24.04-arm |
| 72 | + target: aarch64-unknown-linux-musl |
| 73 | + - runner: ubuntu-24.04-arm |
| 74 | + target: aarch64-unknown-linux-gnu |
| 75 | + - runner: windows-latest |
| 76 | + target: x86_64-pc-windows-msvc |
| 77 | + - runner: windows-11-arm |
| 78 | + target: aarch64-pc-windows-msvc |
| 79 | + |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v5 |
| 82 | + |
| 83 | + with: |
| 84 | + targets: ${{ matrix.target }} |
| 85 | + |
| 86 | + - uses: actions/cache@v4 |
| 87 | + with: |
| 88 | + path: | |
| 89 | + ~/.cargo/bin/ |
| 90 | + ~/.cargo/registry/index/ |
| 91 | + ~/.cargo/registry/cache/ |
| 92 | + ~/.cargo/git/db/ |
| 93 | + ${{ github.workspace }}/codex-rs/target/ |
| 94 | + key: cargo-${{ matrix.runner }}-${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }} |
| 95 | + |
| 96 | + - if: ${{ matrix.target == 'x86_64-unknown-linux-musl' || matrix.target == 'aarch64-unknown-linux-musl'}} |
| 97 | + name: Install musl build tools |
| 98 | + run: | |
| 99 | + sudo apt-get update |
| 100 | + sudo apt-get install -y musl-tools pkg-config |
| 101 | +
|
| 102 | + - name: Cargo build |
| 103 | + run: cargo build --target ${{ matrix.target }} --release --bin codex |
| 104 | + |
| 105 | + - name: Stage artifacts |
| 106 | + shell: bash |
| 107 | + run: | |
| 108 | + dest="dist/${{ matrix.target }}" |
| 109 | + mkdir -p "$dest" |
| 110 | +
|
| 111 | + if [[ "${{ matrix.runner }}" == windows* ]]; then |
| 112 | + cp target/${{ matrix.target }}/release/codex.exe "$dest/codex-${{ matrix.target }}.exe" |
| 113 | + else |
| 114 | + cp target/${{ matrix.target }}/release/codex "$dest/codex-${{ matrix.target }}" |
| 115 | + fi |
| 116 | +
|
| 117 | + - if: ${{ matrix.runner == 'windows-11-arm' }} |
| 118 | + name: Install zstd |
| 119 | + shell: powershell |
| 120 | + run: choco install -y zstandard |
| 121 | + |
| 122 | + - name: Compress artifacts |
| 123 | + shell: bash |
| 124 | + run: | |
| 125 | + dest="dist/${{ matrix.target }}" |
| 126 | +
|
| 127 | + # Create .tar.gz for all platforms and .zip for Windows |
| 128 | + for f in "$dest"/*; do |
| 129 | + base="$(basename "$f")" |
| 130 | + # Skip files that are already archives |
| 131 | + if [[ "$base" == *.tar.gz || "$base" == *.zip ]]; then |
| 132 | + continue |
| 133 | + fi |
| 134 | +
|
| 135 | + # Create per-binary tar.gz |
| 136 | + tar -C "$dest" -czf "$dest/${base}.tar.gz" "$base" |
| 137 | +
|
| 138 | + # Create zip archive for Windows binaries |
| 139 | + if [[ "${{ matrix.runner }}" == windows* ]]; then |
| 140 | + (cd "$dest" && 7z a "${base}.zip" "$base") |
| 141 | + fi |
| 142 | +
|
| 143 | + # Create .zst and remove the original binary |
| 144 | + zstd -T0 -19 --rm "$dest/$base" |
| 145 | + done |
| 146 | +
|
| 147 | + - uses: actions/upload-artifact@v4 |
| 148 | + with: |
| 149 | + name: ${{ matrix.target }} |
| 150 | + path: | |
| 151 | + codex-rs/dist/${{ matrix.target }}/* |
| 152 | +
|
| 153 | + release: |
| 154 | + needs: build |
| 155 | + name: Create Release |
| 156 | + runs-on: ubuntu-latest |
| 157 | + permissions: |
| 158 | + contents: write |
| 159 | + actions: read |
| 160 | + |
| 161 | + steps: |
| 162 | + - name: Checkout repository |
| 163 | + uses: actions/checkout@v5 |
| 164 | + |
| 165 | + - uses: actions/download-artifact@v4 |
| 166 | + with: |
| 167 | + path: dist |
| 168 | + |
| 169 | + - name: List artifacts |
| 170 | + run: ls -R dist/ |
| 171 | + |
| 172 | + - name: Define release name |
| 173 | + id: release_name |
| 174 | + run: | |
| 175 | + version="${GITHUB_REF_NAME#browseros-v}" |
| 176 | + echo "name=${version}" >> $GITHUB_OUTPUT |
| 177 | +
|
| 178 | + - name: Create GitHub Release |
| 179 | + uses: softprops/action-gh-release@v2 |
| 180 | + with: |
| 181 | + name: BrowserOS ${{ steps.release_name.outputs.name }} |
| 182 | + tag_name: ${{ github.ref_name }} |
| 183 | + files: dist/** |
| 184 | + prerelease: ${{ contains(steps.release_name.outputs.name, '-') }} |
0 commit comments