-
Notifications
You must be signed in to change notification settings - Fork 2
103 lines (83 loc) · 2.71 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: ci
on:
push:
tags:
- "v*.*.*"
env:
CARGO_TERM_COLOR: always
jobs:
build-release:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
include:
- 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
targets: "x86_64-apple-darwin,aarch64-apple-darwin"
- os: windows-latest
targets: "x86_64-pc-windows-msvc"
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.targets }}
- name: Install zig
uses: korandoru/setup-zig@v1
if: matrix.os == 'ubuntu-latest'
with:
zig-version: 0.11.0
- name: Install binstall
uses: cargo-bins/cargo-binstall@main
if: matrix.os == 'ubuntu-latest'
- name: Install zigbuild
run: cargo binstall -y cargo-zigbuild
if: matrix.os == 'ubuntu-latest'
- name: Build
shell: pwsh
run: |
("${{ matrix.targets }}" -split ",") | ForEach-Object {
Write-Host "Building $_"
if ("${{ matrix.os }}" -ne "ubuntu-latest") {
cargo build --verbose --release --target $_
} else {
cargo zigbuild --verbose --release --target $_
}
}
- name: List builds
shell: pwsh
run: |
Get-ChildItem (Join-Path . target)
- name: Archive artifacts
shell: pwsh
run: |
$isWin = "${{ matrix.os }}".StartsWith("windows-")
$ext = $isWin ? ".exe" : ""
("${{ matrix.targets }}" -split ",") | ForEach-Object {
$binaryName = "als$ext"
$targetBinaryName = "als-$_$ext"
Move-Item -Path (Join-Path . target $_ release $binaryName) -Destination (Join-Path . $targetBinaryName)
if ($isWin) {
Compress-Archive -Path (Join-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: |
Get-ChildItem .
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: ${{ env.ARCHIVE_PATH }}