-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathazure-pipelines.yml
269 lines (247 loc) · 9.68 KB
/
azure-pipelines.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
trigger:
branches:
include: ["master", "azure-pipelines"]
tags:
include: ["*"]
variables:
rust_test_threads: 1
jobs:
- job: "Frontend"
pool:
vmImage: "ubuntu-latest"
steps:
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: Install Rust
- script: cargo install wasm-pack
displayName: Install Wasm Pack
- script: npm install --prefix ./frontend/ ./frontend/
displayName: Install Frontend Dependencies
- script: npm run build --prefix ./frontend/
displayName: Build Frontend
- publish: $(System.DefaultWorkingDirectory)/frontend
artifact: frontend
- job: "Clippy"
dependsOn: "Frontend"
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
strategy:
matrix:
windows-stable:
imageName: "windows-latest"
rustup_toolchain: stable
linux-stable:
imageName: "ubuntu-latest"
rustup_toolchain: stable
macos-stable:
imageName: "macOS-latest"
rustup_toolchain: stable
pool:
vmImage: $(imageName)
steps:
- script: |
sudo apt update
sudo apt install -y libasound2-dev libudev-dev pkg-config
displayName: Linux Install Dependencies
condition: eq( variables['imageName'], 'ubuntu-latest' )
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: Linux Darwin Install Rust
condition: ne( variables['Agent.OS'], 'Windows_NT' )
- script: |
curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN% --default-host x86_64-pc-windows-msvc
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
displayName: Windows Install Rust
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- download: current
displayName: Download frontend artifact
artifact: frontend
- task: CopyFiles@2
displayName: Copy frontend dist folder
inputs:
sourceFolder: "$(Pipeline.Workspace)/frontend/dist"
contents: "**"
targetFolder: "$(System.DefaultWorkingDirectory)/frontend/dist"
- script: rustup component add clippy
displayName: Install Clippy
- script: cargo clippy
displayName: Run Clippy
- job: "Test"
dependsOn: "Frontend"
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
strategy:
matrix:
windows-stable:
imageName: "windows-latest"
rustup_toolchain: stable
target: "x86_64-pc-windows-msvc"
linux-stable:
imageName: "ubuntu-latest"
rustup_toolchain: stable
target: "x86_64-unknown-linux-gnu"
macos-stable:
imageName: "macOS-latest"
rustup_toolchain: stable
pool:
vmImage: $(imageName)
steps:
- script: |
sudo apt update
sudo apt install -y libasound2-dev libudev-dev pkg-config
displayName: Linux Install Dependencies
condition: eq( variables['imageName'], 'ubuntu-latest' )
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: Linux Darwin Install Rust
condition: ne( variables['Agent.OS'], 'Windows_NT' )
- script: |
curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN% --default-host x86_64-pc-windows-msvc
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
displayName: Windows Install Rust
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- download: current
displayName: Download frontend artifact
artifact: frontend
- task: CopyFiles@2
displayName: Copy frontend dist folder
inputs:
sourceFolder: "$(Pipeline.Workspace)/frontend/dist"
contents: "**"
targetFolder: "$(System.DefaultWorkingDirectory)/frontend/dist"
- script: cargo build
displayName: Cargo Build
- script: cargo test
displayName: Cargo Test
- job: "Release"
dependsOn: "Frontend"
timeoutInMinutes: 0
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
strategy:
matrix:
windows-stable:
imageName: "windows-latest"
rustup_toolchain: stable
target: "x86_64-pc-windows-msvc"
docker: false
linux-stable:
imageName: "ubuntu-latest"
rustup_toolchain: stable
target: "x86_64-unknown-linux-gnu"
docker: false
macos-stable:
imageName: "macOS-latest"
rustup_toolchain: stable
target: "x86_64-apple-darwin"
docker: false
armv7-stable:
imageName: "ubuntu-latest"
rustup_toolchain: stable
target: "armv7-unknown-linux-gnueabihf"
docker: true
aarch64-stable:
imageName: "ubuntu-latest"
rustup_toolchain: stable
target: "aarch64-unknown-linux-gnu"
docker: true
pool:
vmImage: $(imageName)
steps:
- bash: |
DATE="$(date +%Y-%m-%d)"
echo "##vso[task.setvariable variable=build.date]$DATE"
displayName: Create Date Variable
- bash: |
MY_TAG="$(Build.SourceBranch)"
MY_TAG=${MY_TAG#refs/tags/}
echo $MY_TAG
echo "##vso[task.setvariable variable=build.my_tag]$MY_TAG"
displayName: Create Tag Variable
- script: |
sudo apt update
sudo apt install -y libasound2-dev libudev-dev pkg-config
displayName: Linux Install Dependencies
condition: and( eq( variables['imageName'], 'ubuntu-latest' ), eq( variables['docker'], 'false' ))
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: Linux Darwin Install Rust
condition: and( ne( variables['Agent.OS'], 'Windows_NT' ), eq( variables['docker'], 'false' ))
- script: |
curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN% --default-host x86_64-pc-windows-msvc
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
displayName: Windows Install Rust
condition: and( eq( variables['Agent.OS'], 'Windows_NT' ), eq( variables['docker'], 'false' ))
- download: current
displayName: Download frontend artifact
artifact: frontend
- task: CopyFiles@2
displayName: Copy frontend dist folder
inputs:
sourceFolder: "$(Pipeline.Workspace)/frontend/dist"
contents: "**"
targetFolder: "$(System.DefaultWorkingDirectory)/frontend/dist"
- script: cargo build --release
displayName: Cargo Build
condition: eq( variables['docker'], 'false' )
- script: cargo test --release
displayName: Cargo Test
condition: eq( variables['docker'], 'false' )
- script: |
docker build -t tarkah/karaoke-rs:$TARGET ./ci/$TARGET/
displayName: Cross Setup Docker
condition: eq( variables['docker'], 'true' )
- script: |
docker run -v "$(pwd):/source" tarkah/karaoke-rs:$TARGET cargo build --release --manifest-path /source/Cargo.toml --target $TARGET
displayName: Cross Build
condition: eq( variables['docker'], 'true' )
- task: CopyFiles@2
displayName: Copy Binary
inputs:
sourceFolder: "$(Build.SourcesDirectory)"
contents: |
target/**/release/?(karaoke-rs|karaoke-rs.exe)
targetFolder: "$(Build.BinariesDirectory)/karaoke-rs"
flattenFolders: true
- task: CopyFiles@2
displayName: Copy Assets
inputs:
sourceFolder: "$(Build.SourcesDirectory)"
contents: |
README.md
LICENSE
screenshots/**.*
targetFolder: "$(Build.BinariesDirectory)/karaoke-rs"
- task: ArchiveFiles@2
displayName: Linux Darwin Archive
inputs:
rootFolderOrFile: "$(Build.BinariesDirectory)/karaoke-rs"
archiveType: "tar"
tarCompression: "gz"
archiveFile: "$(Build.ArtifactStagingDirectory)/karaoke-rs-$(build.my_tag)-$(TARGET).tar.gz"
condition: ne( variables['Agent.OS'], 'Windows_NT' )
- task: ArchiveFiles@2
displayName: Windows Archive
inputs:
rootFolderOrFile: "$(Build.BinariesDirectory)/karaoke-rs"
archiveType: "zip"
archiveFile: "$(Build.ArtifactStagingDirectory)/karaoke-rs-$(build.my_tag)-$(TARGET).zip"
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- task: GithubRelease@0
displayName: Publish Assets to Github Release
condition: succeeded()
inputs:
gitHubConnection: "tarkah"
repositoryName: "tarkah/karaoke-rs"
action: "edit"
target: "$(build.sourceVersion)"
tagSource: "manual"
tag: "$(build.my_tag)"
assets: "$(Build.ArtifactStagingDirectory)/*"
title: "$(build.my_tag) - $(build.date)"
assetUploadMode: "replace"
addChangeLog: false