-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (130 loc) · 4.1 KB
/
build.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Build
on:
push:
branches: [ "master" ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # Matches version tags like v1.0.0, v2.1.3-rc1, etc.
pull_request:
branches: [ "master" ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install -y libasound2-dev
- name: Test
run: cargo test --verbose
linux-gnu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install -y libasound2-dev
- name: Build
run: cargo build --release --verbose
- name: Test
run: cargo test --verbose
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: insanity-linux-gnu
path: target/release/insanity
linux-musl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Docker Build
run: docker build -t insanity-musl -f Dockerfile.alpine .
- name: Copy artifact
run: |
docker create --name temp-container insanity-musl
docker cp temp-container:/usr/local/cargo/bin/insanity ./insanity
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: insanity-linux-musl
path: insanity
macos-apple-silicon:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Rustup Toolchain
run: rustup toolchain install stable-aarch64-apple-darwin
- name: Rustup Target
run: rustup target add aarch64-apple-darwin
- name: Build
run: cargo +stable-aarch64-apple-darwin build --release --verbose --target aarch64-apple-darwin
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: insanity-apple-silicon
path: target/aarch64-apple-darwin/release/insanity
windows-mingw:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Rustup Toolchain
run: rustup toolchain install --force-non-host stable-x86_64-pc-windows-gnu
- name: Rustup Target
run: rustup target add x86_64-pc-windows-gnu
- name: Build
run: cargo +stable-x86_64-pc-windows-gnu build --release --verbose --target x86_64-pc-windows-gnu
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: insanity-mingw.exe
path: target/x86_64-pc-windows-gnu/release/insanity.exe
windows-msvc:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Rustup Toolchain
run: rustup toolchain install stable-x86_64-pc-windows-msvc
- name: Rustup Target
run: rustup target add x86_64-pc-windows-msvc
- name: Build
run: cargo +stable-x86_64-pc-windows-msvc build --release --verbose --target x86_64-pc-windows-msvc
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: insanity.exe
path: target/x86_64-pc-windows-msvc/release/insanity.exe
nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Nix Build
run: nix --extra-experimental-features nix-command --extra-experimental-features flakes build
- name: Upload build result
uses: actions/[email protected]
with:
name: insanity-nix-package
path: result
release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [linux-gnu, linux-musl, macos-apple-silicon, windows-mingw, windows-msvc, nix]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Zip artifacts
run: |
for f in *; do
if [ -d "$f" ]; then
zip -r "$f.zip" "$f"
rm -rf "$f"
fi
done
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "*"
token: ${{ secrets.GITHUB_TOKEN }}