From 6828d3c8dca52619087aa046454f8f840bf41391 Mon Sep 17 00:00:00 2001 From: nomyfan Date: Tue, 20 Feb 2024 00:12:23 +0800 Subject: [PATCH] . --- .github/workflows/build.yml | 56 ++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67eff91..7c3520b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,18 +14,16 @@ jobs: strategy: fail-fast: false matrix: + os: [ubuntu-latest, macos-14, windows-latest] include: - - os: ubuntu-22.04 - target: x86_64-unknown-linux-gnu + - os: ubuntu-latest + targets: "x86_64-unknown-linux-gnu,x86_64-unknown-linux-musl,aarch64-unknown-linux-musl,aarch64-unknown-linux-gnu" - os: macos-14 - target: x86_64-apple-darwin + targets: "x86_64-apple-darwin,aarch64-apple-darwin" - - os: macos-14 - target: aarch64-apple-darwin - - - os: windows-2022 - target: x86_64-pc-windows-msvc + - os: windows-latest + targets: "x86_64-pc-windows-msvc" runs-on: ${{ matrix.os }} permissions: @@ -38,31 +36,51 @@ jobs: - name: Setup rust toolchain uses: dtolnay/rust-toolchain@stable with: - targets: ${{ matrix.target }} + targets: ${{ matrix.targets }} + + - name: Install zig + uses: korandoru/setup-zig@v1 + with: + zig-version: 0.11.0 + + - name: Install binstall + uses: cargo-bins/cargo-binstall@main - - name: Build - run: cargo build --verbose --release --target ${{ matrix.target }} + - name: Install zigbuild + run: cargo binstall zigbuild + + - name: Cross build + shell: pwsh + run: | + ("${{ matrix.targets }}" -split ",") | ForEach-Object { cargo build --verbose --release --target $_ } - name: List builds shell: pwsh run: | - Get-ChildItem $(Join-Path -Path $(Get-Location) -ChildPath target -AdditionalChildPath ${{ matrix.target }},release) + Get-ChildItem (Join-Path . target) - name: Archive artifacts shell: pwsh run: | $isWin = "${{ matrix.os }}".StartsWith("windows-") - Move-Item -Path $($isWin ? ".\target\${{ matrix.target }}\release\als.exe" : "./target/${{ matrix.target }}/release/als") -Destination . + $ext = $isWin ? ".exe" : "" - $globArchivePath = $isWin ? "./als.${{ matrix.target }}.zip" : "./als.${{ matrix.target }}.tar.gz" - echo "ARCHIVE_PATH=$globArchivePath" >> $env:GITHUB_ENV + ("${{ matrix.targets }}" -split ",") | ForEach-Object { + $binaryName = "als$ext" + $targetBinaryName = "als-$_" + Move-Item -Path (Join-Path . $_ release $binaryName) -Destination (Join-Path . $targetBinaryName) - if ($isWin) { - Compress-Archive -Path .\als.exe -DestinationPath .\als.${{ matrix.target }}.zip - } else { - tar -czf ./als.${{ matrix.target }}.tar.gz ./als + if ($isWin) { + Compress-Archive -Path (Join-Path -Path . $targetBinaryName) -DestinationPath ".\als-$_.zip" + } else { + tar -czf "./als-$_.tar.gz" $targetBinaryName + } + + Remove-Item (Join-Path . $targetBinaryName) } + echo "ARCHIVE_PATH=./als-*" >> $env:GITHUB_ENV + - name: List archive shell: pwsh run: |