Skip to content

Commit b1be863

Browse files
committed
release yaml
1 parent 65107d2 commit b1be863

1 file changed

Lines changed: 204 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)