fix: Improve cross-compilation workflow #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
workflow_dispatch: # Allow manual testing | ||
push: | ||
branches: | ||
- test-release # Test on specific branch | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: x86_64-unknown-linux-gnu,x86_64-apple-darwin,aarch64-apple-darwin,x86_64-pc-windows-msvc | ||
- name: Install cross-compilation tools | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gcc-mingw-w64 clang | ||
- name: Build Linux binary | ||
run: cargo build --release --target x86_64-unknown-linux-gnu | ||
- name: Build macOS binaries (using cross) | ||
run: | | ||
cargo install cross --git https://github.com/cross-rs/cross | ||
cross build --release --target x86_64-apple-darwin | ||
cross build --release --target aarch64-apple-darwin | ||
- name: Build Windows binary | ||
run: | | ||
cross build --release --target x86_64-pc-windows-msvc | ||
- name: Prepare binaries | ||
run: | | ||
# Copy binaries with proper names | ||
cp target/x86_64-unknown-linux-gnu/release/shimmy shimmy-linux-x86_64 | ||
cp target/x86_64-apple-darwin/release/shimmy shimmy-macos-intel | ||
cp target/aarch64-apple-darwin/release/shimmy shimmy-macos-arm64 | ||
cp target/x86_64-pc-windows-msvc/release/shimmy.exe shimmy-windows-x86_64.exe | ||
# Also create generic names for quickstart docs | ||
cp target/x86_64-unknown-linux-gnu/release/shimmy shimmy | ||
cp target/x86_64-pc-windows-msvc/release/shimmy.exe shimmy.exe | ||
# List all created files | ||
ls -la shimmy* | ||
- name: Create release (only on tags) | ||
if: startsWith(github.ref, 'refs/tags/') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release create ${{ github.ref_name }} \ | ||
shimmy-linux-x86_64 \ | ||
shimmy-macos-intel \ | ||
shimmy-macos-arm64 \ | ||
shimmy-windows-x86_64.exe \ | ||
shimmy \ | ||
shimmy.exe \ | ||
--title "Shimmy ${{ github.ref_name }}" \ | ||
--generate-notes |