Skip to content

Merge pull request #99 from warpy-ai/fix_console_calls #27

Merge pull request #99 from warpy-ai/fix_console_calls

Merge pull request #99 from warpy-ai/fix_console_calls #27

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
# Restrict permissions - only release job needs write access
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
artifact_name: oitec
asset_name: oitec-x86_64-apple-darwin
- target: aarch64-apple-darwin
os: macos-latest
artifact_name: oitec
asset_name: oitec-aarch64-apple-darwin
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact_name: oitec
asset_name: oitec-x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
artifact_name: oitec
asset_name: oitec-aarch64-unknown-linux-gnu
steps:
- name: Checkout repository
uses: actions/checkout@v6 # v4.2.2
with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable # stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install LLVM 18 (Ubuntu)
if: runner.os == 'Linux'
run: |
wget -qO- https://apt.llvm.org/llvm.sh -O llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
sudo apt-get install -y libzstd-dev libpolly-18-dev
echo "LLVM_SYS_180_PREFIX=/usr/lib/llvm-18" >> $GITHUB_ENV
- name: Install LLVM 18 (macOS aarch64)
if: runner.os == 'macOS' && matrix.target == 'aarch64-apple-darwin'
run: |
# Remove any pre-installed x86_64 LLVM that could interfere
sudo rm -rf /usr/local/opt/llvm@18 /usr/local/opt/llvm || true
brew install llvm@18 zstd
# Use explicit ARM Homebrew path
echo "LLVM_SYS_180_PREFIX=/opt/homebrew/opt/llvm@18" >> $GITHUB_ENV
- name: Install LLVM 18 (macOS x86_64 cross-compile)
if: runner.os == 'macOS' && matrix.target == 'x86_64-apple-darwin'
run: |
# Install x86_64 Homebrew and LLVM/zstd for the target
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /usr/local/bin/brew install llvm@18 zstd
# Verify x86_64 installation
if [ ! -d "/usr/local/opt/zstd/lib" ]; then
echo "zstd not found at /usr/local/opt/zstd" >&2
exit 1
fi
# Remove libunwind from x86_64 LLVM to prevent it from interfering with arm64 build scripts
# Build scripts run on the host (arm64) and must use system libunwind
rm -f /usr/local/opt/llvm@18/lib/libunwind*.dylib
# Use x86_64 LLVM - llvm-sys needs target-arch LLVM, not host-arch
echo "LLVM_SYS_180_PREFIX=/usr/local/opt/llvm@18" >> $GITHUB_ENV
rustup target add x86_64-apple-darwin
# Create a linker wrapper that forces clang to run under x86_64 (Rosetta)
# This ensures the linker itself runs as x86_64 and properly links x86_64 libraries
sudo tee /usr/local/bin/clang-x86_64 >/dev/null <<'EOF'
#!/bin/sh
exec arch -x86_64 /usr/local/opt/llvm@18/bin/clang "$@"
EOF
sudo chmod +x /usr/local/bin/clang-x86_64
# Debug: show installed zstd architecture
file /usr/local/opt/zstd/lib/libzstd.dylib || true
- name: Cache cargo registry
uses: actions/cache@v4 # v4.2.3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ matrix.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.target }}-cargo-
- name: Build release binary (x86_64 macOS)
if: matrix.target == 'x86_64-apple-darwin'
run: |
# Clean any cached artifacts that might have wrong architecture
cargo clean
# Remove arm64 zstd to prevent linker from finding it
sudo rm -rf /opt/homebrew/opt/zstd
export MACOSX_DEPLOYMENT_TARGET=14.0
# Use x86_64 clang wrapper so the linker runs as x86_64 and picks up x86_64 libs
export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=/usr/local/bin/clang-x86_64
# Ensure the linker sees the x86_64 zstd and llvm libs
export LIBRARY_PATH="/usr/local/opt/zstd/lib:/usr/local/opt/llvm@18/lib"
export CARGO_TARGET_X86_64_APPLE_DARWIN_RUSTFLAGS="-C link-arg=-arch -C link-arg=x86_64 -C link-arg=-L/usr/local/opt/zstd/lib -C link-arg=-lzstd -C link-arg=-L/usr/local/opt/llvm@18/lib -C link-arg=-mmacosx-version-min=14.0"
cargo build --release --target ${{ matrix.target }}
- name: Build release binary
if: matrix.target != 'x86_64-apple-darwin'
run: cargo build --release --target ${{ matrix.target }}
- name: Run tests
if: matrix.target != 'x86_64-apple-darwin'
run: cargo test --release --target ${{ matrix.target }}
- name: Strip binary (Linux)
if: runner.os == 'Linux'
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Strip binary (macOS)
if: runner.os == 'macOS'
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Create tarball
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
cd ../../..
- name: Upload artifact
uses: actions/upload-artifact@v4 # v4.6.2
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}.tar.gz
retention-days: 1
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
# Only this job needs write permissions
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v6 # v4.2.2
with:
persist-credentials: false
- name: Download all artifacts
uses: actions/download-artifact@v4 # v4.3.0
with:
path: artifacts
- name: List artifacts
run: ls -laR artifacts/
- name: Bundle unroll source
run: |
git clone --depth 1 https://github.com/warpy-ai/unroll.git unroll-src-repo
mkdir -p unroll-src
cp -r unroll-src-repo/src unroll-src/
cp unroll-src-repo/unroll.toml unroll-src/ 2>/dev/null || true
tar -czf unroll-src.tar.gz -C unroll-src .
rm -rf unroll-src-repo unroll-src
- name: Generate checksums
run: |
cd artifacts
for dir in */; do
for file in "$dir"*.tar.gz; do
if [ -f "$file" ]; then
sha256sum "$file" >> checksums.txt
fi
done
done
cd ..
sha256sum unroll-src.tar.gz >> artifacts/checksums.txt
sha256sum scripts/install.sh >> artifacts/checksums.txt
cat artifacts/checksums.txt
mv artifacts/checksums.txt .
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2 # v2.2.2
with:
name: Oite ${{ steps.version.outputs.VERSION }}
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
generate_release_notes: true
files: |
artifacts/**/*.tar.gz
unroll-src.tar.gz
scripts/install.sh
checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}