Skip to content

fix(ci): pass GITHUB_TOKEN to macOS build for Z3 source download #6

fix(ci): pass GITHUB_TOKEN to macOS build for Z3 source download

fix(ci): pass GITHUB_TOKEN to macOS build for Z3 source download #6

name: Release CLI
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Git tag to build (e.g. v0.0.36-kagenti.2)"
required: true
type: string
permissions:
contents: write
packages: read
env:
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
ZIG_VERSION: "0.14.1"
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
jobs:
build-cli-linux:
name: Build CLI (Linux amd64)
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
- name: Install Rust toolchain
run: |
rustup toolchain install stable --profile minimal
rustup target add x86_64-unknown-linux-musl
- name: Install Zig
run: |
curl -sSfL "https://ziglang.org/download/${ZIG_VERSION}/zig-x86_64-linux-${ZIG_VERSION}.tar.xz" | tar -xJ
echo "$PWD/zig-x86_64-linux-${ZIG_VERSION}" >> "$GITHUB_PATH"
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y cmake libclang-dev
- name: Cache Rust target and registry
uses: Swatinem/rust-cache@v2
with:
shared-key: cli-musl-amd64
cache-targets: "true"
- name: Set up Zig musl wrappers
run: |
set -euo pipefail
ZIG="$(which zig)"
ZIG_TARGET="x86_64-linux-musl"
mkdir -p /tmp/zig-musl
for tool in cc c++; do
cat > "/tmp/zig-musl/${tool}" << WRAPPER
#!/bin/bash
args=()
for arg in "\$@"; do
case "\$arg" in
--target=*) ;;
*) args+=("\$arg") ;;
esac
done
exec "${ZIG}" ${tool} --target=${ZIG_TARGET} "\${args[@]}"
WRAPPER
chmod +x "/tmp/zig-musl/${tool}"
done
echo "CC_x86_64_unknown_linux_musl=/tmp/zig-musl/cc" >> "$GITHUB_ENV"
echo "CXX_x86_64_unknown_linux_musl=/tmp/zig-musl/c++" >> "$GITHUB_ENV"
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=/tmp/zig-musl/cc" >> "$GITHUB_ENV"
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=-Clink-self-contained=no" >> "$GITHUB_ENV"
echo "CXXSTDLIB=c++" >> "$GITHUB_ENV"
- name: Patch workspace version
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}"
sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${VERSION}"'"/}' Cargo.toml
- name: Build openshell-cli
run: cargo build --release --target x86_64-unknown-linux-musl -p openshell-cli --features bundled-z3
- name: Package binary
run: |
set -euo pipefail
mkdir -p artifacts
tar -czf artifacts/openshell-x86_64-unknown-linux-musl.tar.gz \
-C target/x86_64-unknown-linux-musl/release openshell
ls -lh artifacts/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cli-linux-amd64
path: artifacts/*.tar.gz
retention-days: 30
build-cli-macos:
name: Build CLI (macOS arm64)
runs-on: macos-14
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
- name: Install Rust toolchain
run: rustup toolchain install stable --profile minimal
- name: Cache Rust target and registry
uses: Swatinem/rust-cache@v2
with:
shared-key: cli-macos-arm64
cache-targets: "true"
- name: Patch workspace version
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}"
sed -i '' -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${VERSION}"'"/;}' Cargo.toml
- name: Build openshell-cli
env:
CXXFLAGS: "-std=c++17"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo build --release -p openshell-cli --features bundled-z3
- name: Package binary
run: |
set -euo pipefail
mkdir -p artifacts
tar -czf artifacts/openshell-aarch64-apple-darwin.tar.gz \
-C target/release openshell
ls -lh artifacts/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cli-macos-arm64
path: artifacts/*.tar.gz
retention-days: 30
release:
name: Create Release
needs: [build-cli-linux, build-cli-macos]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release
merge-multiple: true
- name: Generate checksums
working-directory: release
run: |
sha256sum *.tar.gz > openshell-checksums-sha256.txt
cat openshell-checksums-sha256.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: OpenShell ${{ env.RELEASE_TAG }}
tag_name: ${{ env.RELEASE_TAG }}
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
generate_release_notes: true
body: |
## OpenShell CLI ${{ env.RELEASE_TAG }}
### Download
| Platform | Architecture | File |
|----------|-------------|------|
| Linux | x86_64 | `openshell-x86_64-unknown-linux-musl.tar.gz` |
| macOS | Apple Silicon | `openshell-aarch64-apple-darwin.tar.gz` |
### Install
```bash
# Linux amd64
curl -LsSf https://github.com/kagenti/OpenShell/releases/download/${{ env.RELEASE_TAG }}/openshell-x86_64-unknown-linux-musl.tar.gz | tar xz
sudo mv openshell /usr/local/bin/
# macOS Apple Silicon
curl -LsSf https://github.com/kagenti/OpenShell/releases/download/${{ env.RELEASE_TAG }}/openshell-aarch64-apple-darwin.tar.gz | tar xz
sudo mv openshell /usr/local/bin/
```
files: |
release/openshell-x86_64-unknown-linux-musl.tar.gz
release/openshell-aarch64-apple-darwin.tar.gz
release/openshell-checksums-sha256.txt