Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
nomyfan committed Feb 19, 2024
1 parent c7e4da5 commit 6828d3c
Showing 1 changed file with 37 additions and 19 deletions.
56 changes: 37 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |
Expand Down

0 comments on commit 6828d3c

Please sign in to comment.