This repository was archived by the owner on Dec 15, 2025. It is now read-only.
linker issue github action (1) #30
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
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| name: Create Release | ||
| jobs: | ||
| build: | ||
| name: Build and Release | ||
| runs-on: ${{ matrix.os }} | ||
| permissions: | ||
| contents: write | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # Linux builds | ||
| - os: ubuntu-latest | ||
| target: x86_64-unknown-linux-musl | ||
| binary_name: zinit-linux-x86_64 | ||
| - os: ubuntu-latest | ||
| target: aarch64-unknown-linux-musl | ||
| binary_name: zinit-linux-aarch64 | ||
| # macOS builds | ||
| - os: macos-latest | ||
| target: x86_64-apple-darwin | ||
| binary_name: zinit-macos-x86_64 | ||
| - os: macos-latest | ||
| target: aarch64-apple-darwin | ||
| binary_name: zinit-macos-aarch64 | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Cache Rust dependencies | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| target | ||
| key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-${{ matrix.target }}-cargo- | ||
| - name: Setup build environment (macOS) | ||
| if: matrix.os == 'macos-latest' | ||
| run: | | ||
| brew install llvm | ||
| if [[ "${{ matrix.target }}" == "aarch64-apple-darwin" ]]; then | ||
| rustup target add aarch64-apple-darwin | ||
| fi | ||
| - name: Install Rust toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
| target: ${{ matrix.target }} | ||
| override: true | ||
| profile: minimal | ||
| - name: Install MUSL tools (Linux) | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y musl-tools musl-dev | ||
| # Install required Rust targets | ||
| if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-musl" ]]; then | ||
| rustup target add aarch64-unknown-linux-musl | ||
| fi | ||
| if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-musl" ]]; then | ||
| rustup target add x86_64-unknown-linux-musl | ||
| fi | ||
| - name: Setup aarch64 MUSL cross toolchain | ||
| if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-musl' | ||
| uses: taiki-e/setup-cross-toolchain@v1 | ||
| with: | ||
| target: aarch64-unknown-linux-musl | ||
| - name: Build release | ||
| env: | ||
| CC: ${{ matrix.os == 'macos-latest' && 'clang' || '' }} | ||
| CXX: ${{ matrix.os == 'macos-latest' && 'clang++' || '' }} | ||
| MACOSX_DEPLOYMENT_TARGET: '10.12' | ||
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.target == 'aarch64-unknown-linux-musl' && 'aarch64-linux-musl-gcc' || '' }} | ||
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_AR: ${{ matrix.target == 'aarch64-unknown-linux-musl' && 'aarch64-linux-musl-ar' || '' }} | ||
| CC_aarch64_unknown_linux_musl: ${{ matrix.target == 'aarch64-unknown-linux-musl' && 'aarch64-linux-musl-gcc' || '' }} | ||
| run: | | ||
| if [[ "${{ matrix.target }}" == "aarch64-apple-darwin" ]]; then | ||
| export RUSTFLAGS="-C target-feature=+crt-static" | ||
| fi | ||
| cargo build --release --target=${{ matrix.target }} --verbose | ||
| if [ ! -f "target/${{ matrix.target }}/release/zinit" ]; then | ||
| echo "::error::Binary not found at target/${{ matrix.target }}/release/zinit" | ||
| exit 1 | ||
| fi | ||
| - name: Strip binary (Linux) | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: | | ||
| llvm-strip target/${{ matrix.target }}/release/zinit || strip target/${{ matrix.target }}/release/zinit | ||
| - name: Strip binary (macOS) | ||
| if: matrix.os == 'macos-latest' | ||
| run: | | ||
| strip -x target/${{ matrix.target }}/release/zinit || true | ||
| - name: Rename binary | ||
| run: | | ||
| cp target/${{ matrix.target }}/release/zinit ${{ matrix.binary_name }} | ||
| if [ ! -f "${{ matrix.binary_name }}" ]; then | ||
| echo "::error::Binary not copied successfully to ${{ matrix.binary_name }}" | ||
| exit 1 | ||
| fi | ||
| ls -la ${{ matrix.binary_name }} | ||
| file ${{ matrix.binary_name }} || true | ||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ matrix.binary_name }} | ||
| path: ${{ matrix.binary_name }} | ||
| retention-days: 5 | ||
| - name: Upload Release Assets | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| files: ${{ matrix.binary_name }} | ||
| name: Release ${{ github.ref_name }} | ||
| draft: false | ||
| prerelease: false | ||
| fail_on_unmatched_files: false | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||