Skip to content

Commit 462d05b

Browse files
steipeteYuxin-Qiao
andcommitted
ci: publish static musl CLI artifacts
Co-authored-by: Yuxin Qiao <[email protected]>
1 parent 016f3b9 commit 462d05b

7 files changed

Lines changed: 167 additions & 8 deletions

File tree

.github/workflows/release-cli.yml

Lines changed: 155 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,76 @@ jobs:
2222
- name: linux-x64
2323
runs-on: ubuntu-24.04
2424
platform: linux
25+
asset-platform: linux
2526
asset-arch: x86_64
2627
build-arch: ""
2728
static-swift-stdlib: true
29+
swift-sdk: ""
30+
swift-sdk-triple: ""
31+
swift-sdk-arch: ""
32+
file-arch-pattern: x86-64
2833
- name: linux-arm64
2934
runs-on: ubuntu-24.04-arm
3035
platform: linux
36+
asset-platform: linux
3137
asset-arch: aarch64
3238
build-arch: ""
3339
static-swift-stdlib: true
40+
swift-sdk: ""
41+
swift-sdk-triple: ""
42+
swift-sdk-arch: ""
43+
file-arch-pattern: aarch64
44+
- name: linux-musl-x64
45+
runs-on: ubuntu-24.04
46+
platform: linux
47+
asset-platform: linux-musl
48+
asset-arch: x86_64
49+
build-arch: ""
50+
static-swift-stdlib: false
51+
swift-sdk: swift-6.2.1-RELEASE_static-linux-0.0.1
52+
swift-sdk-triple: x86_64-swift-linux-musl
53+
swift-sdk-arch: x86_64
54+
file-arch-pattern: x86-64
55+
- name: linux-musl-arm64
56+
runs-on: ubuntu-24.04-arm
57+
platform: linux
58+
asset-platform: linux-musl
59+
asset-arch: aarch64
60+
build-arch: ""
61+
static-swift-stdlib: false
62+
swift-sdk: swift-6.2.1-RELEASE_static-linux-0.0.1
63+
swift-sdk-triple: aarch64-swift-linux-musl
64+
swift-sdk-arch: aarch64
65+
file-arch-pattern: aarch64
3466
- name: macos-arm64
3567
runs-on: macos-15
3668
platform: macos
69+
asset-platform: macos
3770
asset-arch: arm64
3871
build-arch: arm64
3972
static-swift-stdlib: false
73+
swift-sdk: ""
74+
swift-sdk-triple: ""
75+
swift-sdk-arch: ""
76+
file-arch-pattern: ""
4077
- name: macos-x86_64
4178
runs-on: macos-15-intel
4279
platform: macos
80+
asset-platform: macos
4381
asset-arch: x86_64
4482
build-arch: x86_64
4583
static-swift-stdlib: false
84+
swift-sdk: ""
85+
swift-sdk-triple: ""
86+
swift-sdk-arch: ""
87+
file-arch-pattern: ""
4688
runs-on: ${{ matrix.runs-on }}
4789
env:
4890
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
91+
SWIFT_STATIC_LINUX_SDK_URL: https://download.swift.org/swift-6.2.1-release/static-sdk/swift-6.2.1-RELEASE/swift-6.2.1-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz
92+
SWIFT_STATIC_LINUX_SDK_CHECKSUM: 08e1939a504e499ec871b36826569173103e4562769e12b9b8c2a50f098374ad
93+
SQLITE_AMALGAMATION_VERSION: "3530200"
94+
SQLITE_AMALGAMATION_SHA3_256: 81142986038e18f96c4a54e1a72562ae17e502a916f2a7701eff43388cbf1a40
4995
steps:
5096
- uses: actions/checkout@v6
5197

@@ -118,14 +164,112 @@ jobs:
118164
hash -r
119165
swift --version
120166
167+
- name: Install Swift Static Linux SDK
168+
if: matrix.swift-sdk != ''
169+
shell: bash
170+
run: |
171+
set -euo pipefail
172+
swift sdk install "$SWIFT_STATIC_LINUX_SDK_URL" --checksum "$SWIFT_STATIC_LINUX_SDK_CHECKSUM"
173+
swift sdk list | grep -Fx "${{ matrix.swift-sdk }}"
174+
175+
sdk_root="$(
176+
find "$HOME" -type d -path "*/${{ matrix.swift-sdk }}.artifactbundle/${{ matrix.swift-sdk }}/swift-linux-musl" | head -n1
177+
)"
178+
if [[ -z "$sdk_root" ]]; then
179+
echo "Swift SDK root not found." >&2
180+
exit 1
181+
fi
182+
183+
python3 - "$sdk_root/swift-sdk.json" "${{ matrix.swift-sdk-triple }}" <<'PY'
184+
import json
185+
import sys
186+
187+
sdk_json_path, target_triple = sys.argv[1], sys.argv[2]
188+
with open(sdk_json_path, encoding="utf-8") as handle:
189+
sdk_json = json.load(handle)
190+
191+
target_triples = sdk_json.get("targetTriples", {})
192+
if target_triple not in target_triples:
193+
raise SystemExit(f"Swift SDK target triple not found: {target_triple}")
194+
195+
sdk_json["targetTriples"] = {target_triple: target_triples[target_triple]}
196+
with open(sdk_json_path, "w", encoding="utf-8") as handle:
197+
json.dump(sdk_json, handle, indent=2)
198+
handle.write("\n")
199+
PY
200+
201+
for sdk_arch in "$sdk_root"/musl-1.2.5.sdk/*; do
202+
if [[ "$(basename "$sdk_arch")" != "${{ matrix.swift-sdk-arch }}" ]]; then
203+
rm -rf "$sdk_arch"
204+
fi
205+
done
206+
207+
- name: Build static SQLite for musl SDK
208+
if: matrix.swift-sdk != ''
209+
shell: bash
210+
run: |
211+
set -euo pipefail
212+
213+
missing_packages=()
214+
for tool in clang openssl unzip; do
215+
if ! command -v "$tool" >/dev/null 2>&1; then
216+
missing_packages+=("$tool")
217+
fi
218+
done
219+
if [[ "${#missing_packages[@]}" -gt 0 ]]; then
220+
sudo apt-get update
221+
sudo apt-get install -y "${missing_packages[@]}"
222+
fi
223+
224+
sqlite_zip="$RUNNER_TEMP/sqlite-amalgamation-${SQLITE_AMALGAMATION_VERSION}.zip"
225+
sqlite_src="$RUNNER_TEMP/sqlite-src"
226+
sqlite_out="$RUNNER_TEMP/sqlite-${{ matrix.swift-sdk-triple }}"
227+
228+
curl -fsSL "https://www.sqlite.org/2026/sqlite-amalgamation-${SQLITE_AMALGAMATION_VERSION}.zip" -o "$sqlite_zip"
229+
actual_sha3="$(openssl dgst -sha3-256 "$sqlite_zip" | awk '{print $NF}')"
230+
if [[ "$actual_sha3" != "$SQLITE_AMALGAMATION_SHA3_256" ]]; then
231+
echo "SQLite amalgamation checksum mismatch: $actual_sha3" >&2
232+
exit 1
233+
fi
234+
235+
rm -rf "$sqlite_src" "$sqlite_out"
236+
mkdir -p "$sqlite_src" "$sqlite_out/build" "$sqlite_out/lib"
237+
unzip -q "$sqlite_zip" -d "$sqlite_src"
238+
239+
sdk_bundle="$(
240+
find "$HOME" -type d -name "${{ matrix.swift-sdk }}.artifactbundle" | head -n1
241+
)"
242+
if [[ -z "$sdk_bundle" ]]; then
243+
echo "Swift SDK artifact bundle not found." >&2
244+
exit 1
245+
fi
246+
sysroot="$sdk_bundle/${{ matrix.swift-sdk }}/swift-linux-musl/musl-1.2.5.sdk/${{ matrix.swift-sdk-arch }}"
247+
if [[ ! -d "$sysroot" ]]; then
248+
echo "Swift SDK sysroot not found: $sysroot" >&2
249+
exit 1
250+
fi
251+
252+
clang \
253+
-target "${{ matrix.swift-sdk-triple }}" \
254+
--sysroot="$sysroot" \
255+
-O2 \
256+
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
257+
-c "$sqlite_src/sqlite-amalgamation-${SQLITE_AMALGAMATION_VERSION}/sqlite3.c" \
258+
-o "$sqlite_out/build/sqlite3.o"
259+
llvm-ar crs "$sqlite_out/lib/libsqlite3.a" "$sqlite_out/build/sqlite3.o"
260+
261+
echo "CODEXBAR_SQLITE3_LIB_DIR=$sqlite_out/lib" >> "$GITHUB_ENV"
262+
121263
- name: Build CodexBarCLI (release)
122264
id: build
123265
shell: bash
124266
run: |
125267
set -euo pipefail
126268
127269
BUILD_ARGS=(swift build -c release --product CodexBarCLI)
128-
if [[ -n "${{ matrix.build-arch }}" ]]; then
270+
if [[ -n "${{ matrix.swift-sdk }}" ]]; then
271+
BUILD_ARGS+=(--swift-sdk "${{ matrix.swift-sdk }}" --triple "${{ matrix.swift-sdk-triple }}")
272+
elif [[ -n "${{ matrix.build-arch }}" ]]; then
129273
BUILD_ARGS+=(--arch "${{ matrix.build-arch }}")
130274
fi
131275
if [[ "${{ matrix.static-swift-stdlib }}" == "true" ]]; then
@@ -134,7 +278,9 @@ jobs:
134278
"${BUILD_ARGS[@]}"
135279
136280
SHOW_BIN_ARGS=(swift build -c release --product CodexBarCLI --show-bin-path)
137-
if [[ -n "${{ matrix.build-arch }}" ]]; then
281+
if [[ -n "${{ matrix.swift-sdk }}" ]]; then
282+
SHOW_BIN_ARGS+=(--swift-sdk "${{ matrix.swift-sdk }}" --triple "${{ matrix.swift-sdk-triple }}")
283+
elif [[ -n "${{ matrix.build-arch }}" ]]; then
138284
SHOW_BIN_ARGS+=(--arch "${{ matrix.build-arch }}")
139285
fi
140286
if [[ "${{ matrix.static-swift-stdlib }}" == "true" ]]; then
@@ -184,9 +330,14 @@ jobs:
184330
if [[ "${{ matrix.platform }}" == "macos" ]]; then
185331
lipo -archs "$BIN" | tr ' ' '\n' | grep -Fx "${{ matrix.asset-arch }}"
186332
run_with_timeout "$RUNNER_TEMP/codexbar-cli-smoke-${{ matrix.name }}.txt" "$BIN" config validate --format json
333+
elif [[ -n "${{ matrix.swift-sdk }}" ]]; then
334+
run_with_timeout "$RUNNER_TEMP/codexbar-cli-help-${{ matrix.name }}.txt" "$BIN" --help
335+
run_with_timeout "$RUNNER_TEMP/codexbar-cli-config-${{ matrix.name }}.json" "$BIN" config validate --format json
336+
file "$BIN" | grep -q "${{ matrix.file-arch-pattern }}"
337+
file "$BIN" | grep -q "statically linked"
187338
else
188339
run_with_timeout "$RUNNER_TEMP/codexbar-cli-help-${{ matrix.name }}.txt" "$BIN" --help
189-
file "$BIN" | grep -q "${{ matrix.asset-arch }}"
340+
file "$BIN" | grep -q "${{ matrix.file-arch-pattern }}"
190341
fi
191342
printf '%s\n' "${RELEASE_TAG#v}" > "$BIN_DIR/VERSION"
192343
VERSION_OUTPUT="$RUNNER_TEMP/codexbar-cli-version-${{ matrix.name }}.txt"
@@ -213,7 +364,7 @@ jobs:
213364
ln -s "CodexBarCLI" "$OUT_DIR/codexbar"
214365
printf '%s\n' "${SAFE_REF_NAME#v}" > "$OUT_DIR/VERSION"
215366
216-
ASSET="CodexBarCLI-${SAFE_REF_NAME}-${{ matrix.platform }}-${{ matrix.asset-arch }}.tar.gz"
367+
ASSET="CodexBarCLI-${SAFE_REF_NAME}-${{ matrix.asset-platform }}-${{ matrix.asset-arch }}.tar.gz"
217368
(cd "$OUT_DIR" && tar czf "$ASSET" CodexBarCLI codexbar VERSION)
218369
if command -v sha256sum >/dev/null 2>&1; then
219370
sha256sum "$OUT_DIR/$ASSET" > "$OUT_DIR/$ASSET.sha256"

.mac-release.env

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ MAC_RELEASE_EXTRA_ASSET_PATTERNS='^CodexBarCLI-v${MARKETING_VERSION}-macos-arm64
3434
^CodexBarCLI-v${MARKETING_VERSION}-linux-aarch64\.tar\.gz$
3535
^CodexBarCLI-v${MARKETING_VERSION}-linux-aarch64\.tar\.gz\.sha256$
3636
^CodexBarCLI-v${MARKETING_VERSION}-linux-x86_64\.tar\.gz$
37-
^CodexBarCLI-v${MARKETING_VERSION}-linux-x86_64\.tar\.gz\.sha256$'
37+
^CodexBarCLI-v${MARKETING_VERSION}-linux-x86_64\.tar\.gz\.sha256$
38+
^CodexBarCLI-v${MARKETING_VERSION}-linux-musl-aarch64\.tar\.gz$
39+
^CodexBarCLI-v${MARKETING_VERSION}-linux-musl-aarch64\.tar\.gz\.sha256$
40+
^CodexBarCLI-v${MARKETING_VERSION}-linux-musl-x86_64\.tar\.gz$
41+
^CodexBarCLI-v${MARKETING_VERSION}-linux-musl-x86_64\.tar\.gz\.sha256$'

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 0.36.2 — Unreleased
44

55
### Added
6+
- Linux CLI: publish static musl release tarballs for x86_64 and aarch64. Thanks @Yuxin-Qiao!
67
- Codex agents: add a read-only `codexbar` skill for bounded, redacted provider usage JSON. Thanks @coygeek!
78
- Display: add a Hide critters option for plain menu bar quota capsules. Thanks @elijahfriedman!
89

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ yay -S codexbar-cli
4646
```
4747
Or download release tarballs from GitHub Releases:
4848
- macOS: `CodexBarCLI-v<tag>-macos-arm64.tar.gz`, `CodexBarCLI-v<tag>-macos-x86_64.tar.gz`
49-
- Linux: `CodexBarCLI-v<tag>-linux-aarch64.tar.gz`, `CodexBarCLI-v<tag>-linux-x86_64.tar.gz`
49+
- Linux (glibc): `CodexBarCLI-v<tag>-linux-aarch64.tar.gz`, `CodexBarCLI-v<tag>-linux-x86_64.tar.gz`
50+
- Linux (static musl): `CodexBarCLI-v<tag>-linux-musl-aarch64.tar.gz`, `CodexBarCLI-v<tag>-linux-musl-x86_64.tar.gz`
5051

5152
### First run
5253
- Open Settings → Providers and enable what you use.

docs/RELEASING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Uploads not handled automatically—commit/publish appcast + zip to the feed loc
7373
CodexBar ships a Homebrew **Cask** in `../homebrew-tap`. When installed via Homebrew, CodexBar disables Sparkle and the app
7474
must be updated via `brew`.
7575

76-
After publishing the GitHub release, `.github/workflows/release-cli.yml` builds the CLI tarballs, uploads `CodexBarCLI-v<version>-{macos-arm64,macos-x86_64,linux-aarch64,linux-x86_64}.tar.gz` plus checksums, then dispatches the Homebrew tap update for both the CLI formula and app cask. If the final dispatch is rate-limited, the tarballs and app zip may still be present; rerun or manually update the tap formula/cask from the published assets.
76+
After publishing the GitHub release, `.github/workflows/release-cli.yml` builds the macOS, glibc Linux, and static musl Linux CLI tarballs for arm64 and x86_64, uploads them plus checksums, then dispatches the Homebrew tap update for both the CLI formula and app cask. Homebrew continues to use the glibc Linux assets. If the final dispatch is rate-limited, the tarballs and app zip may still be present; rerun or manually update the tap formula/cask from the published assets.
7777

7878
## Checklist (quick)
7979
- [ ] Read both this file and `~/Projects/agent-scripts/docs/RELEASING-MAC.md`; resolve any conflicts toward CodexBar’s specifics.

docs/cli.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Use it when you need usage numbers in scripts, CI, or dashboards without UI.
2020
- Homebrew formula (Linux today): `brew install steipete/tap/codexbar`.
2121
- Download release tarballs from GitHub Releases:
2222
- macOS: `CodexBarCLI-v<tag>-macos-arm64.tar.gz`, `CodexBarCLI-v<tag>-macos-x86_64.tar.gz`
23-
- Linux: `CodexBarCLI-v<tag>-linux-aarch64.tar.gz`, `CodexBarCLI-v<tag>-linux-x86_64.tar.gz`
23+
- Linux (glibc): `CodexBarCLI-v<tag>-linux-aarch64.tar.gz`, `CodexBarCLI-v<tag>-linux-x86_64.tar.gz`
24+
- Linux (static musl): `CodexBarCLI-v<tag>-linux-musl-aarch64.tar.gz`, `CodexBarCLI-v<tag>-linux-musl-x86_64.tar.gz`
2425
- Extract and run `./codexbar` (symlink) or `./CodexBarCLI`.
2526

2627
```

docs/releasing-homebrew.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ In `../homebrew-tap`, update the formula at `Formula/codexbar.rb`:
3636
- macOS: `.../releases/download/v<version>/CodexBarCLI-v<version>-macos-x86_64.tar.gz`
3737
- Linux: `.../releases/download/v<version>/CodexBarCLI-v<version>-linux-aarch64.tar.gz`
3838
- Linux: `.../releases/download/v<version>/CodexBarCLI-v<version>-linux-x86_64.tar.gz`
39+
- Static musl tarballs are also published for manual Linux installs as `linux-musl-aarch64` and `linux-musl-x86_64`; keep the formula on the glibc assets unless intentionally changing its runtime contract.
3940
- Update all `sha256` values to match those tarballs.
4041

4142
## 3) Verify install

0 commit comments

Comments
 (0)