-
Notifications
You must be signed in to change notification settings - Fork 24
/
azure-pipelines.yml
458 lines (425 loc) · 17.1 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
strategy:
maxParallel: 3
matrix:
windows:
jobArchName: 'Windows'
imageName: 'windows-latest'
agentArch: 'windows'
artifactPrefix: 'windows.'
artifactSuffix: ''
netBuildOS: 'win-x86'
lualibs: 'prebuilt'
loveURL: 'https://github.com/love2d/love/releases/download/11.5/love-11.5-win32.zip'
loveLuaURL: 'https://github.com/love2d/love/releases/download/11.3/love-11.3-win32.zip'
loveZIP: 'love.zip'
loveAppImage: ''
loveBinaryDirectory: ''
loveResourcesDirectory: ''
loveBinary: 'love.exe'
macos:
jobArchName: 'macOS'
imageName: 'macOS-latest'
agentArch: 'macOS'
artifactPrefix: 'macos.'
artifactSuffix: ''
netBuildOS: 'osx-x64'
lualibs: 'luarocks'
luarocksPreArgs: '--lua-dir=/usr/local/opt/[email protected]'
luarocksArgs: 'LUA_LIBDIR="/usr/local/opt/[email protected]/lib"'
loveURL: 'https://github.com/love2d/love/releases/download/11.5/love-11.5-macos.zip'
loveLuaURL: ''
loveZIP: 'love.zip'
loveAppImage: ''
loveBinaryDirectory: 'love.app/Contents/MacOS/'
loveResourcesDirectory: 'love.app/Contents/Resources/'
launcher: ''
linux:
jobArchName: 'linux'
imageName: 'ubuntu-20.04'
agentArch: 'linux'
artifactPrefix: 'linux.'
artifactSuffix: ''
netBuildOS: 'linux-x64'
lualibs: 'luarocks'
luarocksArgs: 'LUA_LIBDIR="/usr/local/opt/lua/lib"'
loveURL: 'https://github.com/love2d/love/releases/download/11.5/love-11.5-x86_64.AppImage'
loveLuaURL: ''
loveZIP: ''
loveAppImage: 'love-raw/love'
loveBinaryDirectory: ''
loveResourcesDirectory: ''
launcher: ''
name: '$(Date:yy.MM.dd)$(Rev:.rr)'
pool:
vmImage: '$(imageName)'
steps:
- checkout: self
clean: false
fetchDepth: 3
lfs: false
submodules: recursive
# Prepare dependencies.
# Use brew on macOS.
- task: CmdLine@2
condition: and(succeeded(), eq(variables.agentArch, 'macOS'))
displayName: 'Setup: macOS: brew: install lua [email protected] luarocks'
inputs:
script: |
export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_INSTALL_FROM_API=1
brew tap homebrew/core
sed -i.bak 's/disable/deprecate/' /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/l/[email protected]
brew install lua [email protected] luarocks
# Use apt on Ubuntu.
- task: CmdLine@2
condition: and(succeeded(), eq(variables.agentArch, 'linux'))
displayName: 'Setup: Linux: apt: install luarocks and deps'
inputs:
script: |
sudo apt -y update && sudo apt -y install luarocks libgtk-3-dev
# Cross-platform setup.
- task: CmdLine@2
condition: and(succeeded(), eq(variables.lualibs, 'luarocks'))
displayName: 'Setup: luarocks: config'
inputs:
script: |
git config --global url."https://github.com/".insteadOf git://github.com/
luarocks config lua_version 5.1
luarocks
# Build LuaRocks depdencies.
# Install subprocess.
- task: CmdLine@2
condition: and(succeeded(), eq(variables.lualibs, 'luarocks'))
displayName: 'Build: luarocks: install subprocess'
inputs:
script: |
luarocks $LUAROCKSPREARGS install --tree=luarocks https://raw.githubusercontent.com/0x0ade/lua-subprocess/master/subprocess-scm-1.rockspec $LUAROCKSARGS
# Install nfd.
- task: CmdLine@2
condition: and(succeeded(), eq(variables.lualibs, 'luarocks'))
displayName: 'Build: luarocks: install nfd'
inputs:
script: |
luarocks $LUAROCKSPREARGS install --tree=luarocks https://raw.githubusercontent.com/Vexatos/nativefiledialog/master/lua/nfd-scm-1.rockspec $LUAROCKSARGS
# Install lsqlite3complete.
- task: CmdLine@2
condition: and(succeeded(), eq(variables.lualibs, 'luarocks'))
displayName: 'Build: luarocks: install lsqlite3complete'
inputs:
script: |
luarocks $LUAROCKSPREARGS install --tree=luarocks lsqlite3complete $LUAROCKSARGS
# Build sharp.
- task: DotNetCoreCLI@2
displayName: 'Build: dotnet: restore sharp'
inputs:
command: 'restore'
projects: 'sharp/*.csproj'
- task: DotNetCoreCLI@2
displayName: 'Build: dotnet: build sharp'
inputs:
command: 'publish'
projects: 'sharp/*.csproj'
publishWebProjects: false
zipAfterPublish: false
arguments: '--runtime $(netBuildOS) --self-contained'
# Build launcher-winforms.
- task: UseDotNet@2
condition: and(succeeded(), eq(variables.agentArch, 'windows'))
displayName: 'Build: downgrade .NET to build launcher-winforms'
inputs:
version: 7.x # "Fixes" BinaryFormatter issues to circumvent a il-repack issue: https://github.com/gluck/il-repack/issues/327
- task: DotNetCoreCLI@2
condition: and(succeeded(), eq(variables.agentArch, 'windows'))
displayName: 'Build: dotnet: restore launcher-winforms'
inputs:
command: 'restore'
projects: 'launcher-winforms/*.csproj'
- task: DotNetCoreCLI@2
condition: and(succeeded(), eq(variables.agentArch, 'windows'))
displayName: 'Build: dotnet: build launcher-winforms'
inputs:
command: 'build'
projects: 'launcher-winforms/*.csproj'
arguments: '--configuration Release'
# Build uninstaller-winforms.
- task: DotNetCoreCLI@2
condition: and(succeeded(), eq(variables.agentArch, 'windows'))
displayName: 'Build: dotnet: restore uninstaller-winforms'
inputs:
command: 'restore'
projects: 'uninstaller-winforms/*.csproj'
- task: DotNetCoreCLI@2
condition: and(succeeded(), eq(variables.agentArch, 'windows'))
displayName: 'Build: dotnet: build uninstaller-winforms'
inputs:
command: 'build'
projects: 'uninstaller-winforms/*.csproj'
arguments: '--configuration Release'
# Create a dummy dir for platforms which don't use prebuilt LÖVE.
- task: CmdLine@2
condition: and(succeeded(), eq(variables.loveZIP, ''))
displayName: 'Dist: Create empty LÖVE dir for sad and lonely penguins'
continueOnError: true
inputs:
script: |
mkdir -p love-raw
# Create and publish an artifact.
# Download and unpack LÖVE.
- task: Cache@2
condition: and(succeeded(), ne(variables.loveURL, ''))
displayName: 'Dist: Grab cached LÖVE'
inputs:
key: 'love-unpacked | "$(Agent.OS)"'
path: love-raw
cacheHitVar: loveCached
- task: PowerShell@2
condition: and(succeeded(), ne(variables.loveURL, ''), ne(variables.loveCached, 'true'))
displayName: 'Dist: Download LÖVE'
continueOnError: true
inputs:
targetType: 'inline'
script: |
Invoke-WebRequest -Uri $env:LOVEURL -OutFile $env:LOVEZIP$env:LOVEAPPIMAGE
# Unzip love.zip.
- task: PowerShell@2
condition: and(succeeded(), ne(variables.loveZIP, ''), ne(variables.loveCached, 'true'))
displayName: 'Dist: Unpack LÖVE (ZIP)'
continueOnError: true
inputs:
targetType: 'inline'
script: |
Expand-Archive -Path $env:LOVEZIP -DestinationPath love-raw
# If we need to pull lua51.dll from another LÖVE package, download, unzip and grab lua51.dll.
- task: PowerShell@2
condition: and(succeeded(), ne(variables.loveLuaURL, ''), ne(variables.loveCached, 'true'))
displayName: 'Dist: Replace lua51.dll'
continueOnError: true
inputs:
targetType: 'inline'
script: |
Invoke-WebRequest -Uri $env:LOVELUAURL -OutFile lovelua.zip
Expand-Archive -Path lovelua.zip -DestinationPath lovelua
Copy-Item -Path lovelua/love-11.3-win32/lua51.dll -Destination love-raw/love-11.5-win32/lua51.dll -Force
# Copy cached unpacked LÖVE, fix it up if needed
- task: PowerShell@2
condition: and(succeeded(), ne(variables.loveURL, ''))
displayName: 'Dist: Copy and fix cached LÖVE'
continueOnError: true
inputs:
targetType: 'inline'
script: |
Copy-Item -Path love-raw -Destination love -Recurse
if (Test-Path -Path love/love-11.5-win32 -PathType Container) {
Move-Item -Path love/love-11.5-win32 -Destination love-win
Remove-Item -Path love -Force -Recurse
Move-Item -Path love-win -Destination love
Invoke-WebRequest -Uri "https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x64.exe" -OutFile rcedit.exe
./rcedit.exe love/love.exe `
--set-icon icon.ico `
--set-version-string Comments $env:BUILD_SOURCEVERSION `
--set-version-string CompanyName "Everest Team" `
--set-version-string FileDescription Olympus `
--set-version-string FileVersion $env:BUILD_BUILDNUMBER `
--set-version-string LegalCopyright "See https://github.com/EverestAPI/Olympus/blob/main/LICENSE" `
--set-version-string OriginalFilename main.exe `
--set-version-string ProductName Olympus `
--set-version-string ProductVersion $env:BUILD_BUILDNUMBER
}
# Update the version.txt in the src dir based on the build number.
- task: PowerShell@2
condition: succeeded()
displayName: 'Dist: Update src/version.txt'
continueOnError: true
inputs:
targetType: 'inline'
script: |
echo "${env:BUILD_BUILDNUMBER}-azure-${env:BUILD_BUILDID}-$(($env:BUILD_SOURCEVERSION).Substring(0, 5))" | Set-Content src/version.txt
# Bundle src into olympus.love.
- task: PowerShell@2
condition: succeeded()
displayName: 'Dist: Bundle olympus.love'
continueOnError: true
inputs:
targetType: 'inline'
script: |
Compress-Archive -Path src/* -DestinationPath olympus.zip
Move-Item -Path olympus.zip -Destination olympus.love
Copy-Item -Path olympus.love -Destination love/$env:LOVEBINARYDIRECTORY/olympus.love
# Glue it onto the love binary.
- task: PowerShell@2
condition: and(succeeded(), ne(variables.loveBinary, ''))
displayName: 'Dist: Glue olympus.love onto LÖVE'
continueOnError: true
inputs:
targetType: 'inline'
script: |
if ($PSVersionTable.PSVersion.Major -lt 6) {
Get-Content love/$env:LOVEBINARYDIRECTORY/$env:LOVEBINARY,love/$env:LOVEBINARYDIRECTORY/olympus.love -Encoding Byte -ReadCount 512 | Set-Content love-glued -Encoding Byte
} else {
Get-Content love/$env:LOVEBINARYDIRECTORY/$env:LOVEBINARY,love/$env:LOVEBINARYDIRECTORY/olympus.love -AsByteStream -ReadCount 0 | Set-Content love-glued -AsByteStream
}
Remove-Item -Path love/$env:LOVEBINARYDIRECTORY/$env:LOVEBINARY -Force
Move-Item -Path love-glued -Destination love/$env:LOVEBINARYDIRECTORY/$env:LOVEBINARY
Remove-Item -Path love/$env:LOVEBINARYDIRECTORY/olympus.love -Force
# Copy luarocks.
- task: CopyFiles@2
condition: and(succeeded(), eq(variables.lualibs, 'luarocks'))
displayName: 'Dist: Copy luarocks'
continueOnError: true
inputs:
sourceFolder: '$(Build.SourcesDirectory)/luarocks/lib/lua'
contents: '**/*'
targetFolder: 'love/$(loveBinaryDirectory)'
cleanTargetFolder: false
overWrite: true
flattenFolders: true
# Copy prebuilt libs.
- task: CopyFiles@2
displayName: 'Dist: Copy prebuilt libs'
continueOnError: true
inputs:
sourceFolder: '$(Build.SourcesDirectory)/lib-$(agentArch)'
contents: '**/*'
targetFolder: 'love/$(loveBinaryDirectory)'
cleanTargetFolder: false
overWrite: true
flattenFolders: false
# Copy sharp.
- task: CopyFiles@2
condition: succeeded()
displayName: 'Dist: Copy sharp'
continueOnError: true
inputs:
sourceFolder: '$(Build.SourcesDirectory)/sharp/bin/Release/net8.0/$(netBuildOS)/publish'
contents: '**/*'
targetFolder: 'love/$(loveBinaryDirectory)/sharp'
cleanTargetFolder: false
overWrite: true
flattenFolders: true
# Per-platform bundling steps.
# Windows
- task: PowerShell@2
condition: and(succeeded(), eq(variables.agentArch, 'windows'))
displayName: 'Dist: Windows: Finish'
continueOnError: true
inputs:
targetType: 'inline'
script: |
Remove-Item -Path love/changes.txt -Force
Remove-Item -Path love/game.ico -Force
Remove-Item -Path love/love.ico -Force
Remove-Item -Path love/lovec.exe -Force
Move-Item -Path love/love.exe -Destination love/main.exe
New-Item -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY/main -ItemType Directory
Copy-Item -Path uninstaller-winforms/bin/Release/net452/Olympus.exe -Destination love/uninstall.exe
Compress-Archive -Path love/* -DestinationPath $env:BUILD_ARTIFACTSTAGINGDIRECTORY/main/dist.zip -Force
New-Item -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY/update -ItemType Directory
New-Item -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY/platform-update -ItemType Directory
Copy-Item -Path olympus.love -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY/update/olympus.love
Compress-Archive -Path love/sharp/* -DestinationPath $env:BUILD_ARTIFACTSTAGINGDIRECTORY/platform-update/sharp.zip -Force
New-Item -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY/launcher-winforms -ItemType Directory
Copy-Item -Path launcher-winforms/bin/Release/net452/Olympus.exe -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY/launcher-winforms/Olympus.exe
# macOS
- task: CmdLine@2
condition: and(succeeded(), eq(variables.agentArch, 'macOS'))
displayName: 'Dist: macOS: Finish'
continueOnError: true
inputs:
script: |
PLIST=love/love.app/Contents/Info.plist
rm $PLIST
mv love/$LOVEBINARYDIRECTORY/Info.plist $PLIST
APPICON="love/love.app/Contents/Resources/OS X AppIcon.icns"
GAMEICON=love/love.app/Contents/Resources/GameIcon.icns
rm "$APPICON"
rm $GAMEICON
mv love/$LOVEBINARYDIRECTORY/AppIcon.icns "$APPICON"
cp "$APPICON" $GAMEICON
plutil -replace CFBundleShortVersionString -string "$BUILD_BUILDNUMBER" $PLIST
plutil -insert LSArchitecturePriority -array $PLIST
plutil -insert LSArchitecturePriority -string x86_64 -append $PLIST
git clone https://luajit.org/git/luajit-2.0.git
pushd luajit-2.0
git checkout ec6edc5c39c25e4eb3fca51b753f9995e97215da
MACOSX_DEPLOYMENT_TARGET=10.7 make
popd
cp -f luajit-2.0/src/libluajit.so love/love.app/Contents/Frameworks/Lua.framework/Versions/A/Lua
cp olympus.sh love/$LOVEBINARYDIRECTORY/olympus.sh
chmod a+rx love/$LOVEBINARYDIRECTORY/olympus.sh
cp find-love.sh love/$LOVEBINARYDIRECTORY/find-love
chmod a+rx love/$LOVEBINARYDIRECTORY/find-love
chmod a+rx love/$LOVEBINARYDIRECTORY/love
chmod a+rx love/$LOVEBINARYDIRECTORY/sharp/Olympus.Sharp
codesign --remove-signature love/$LOVEBINARYDIRECTORY/love
mkdir $BUILD_ARTIFACTSTAGINGDIRECTORY/platform-update
pushd love/$LOVEBINARYDIRECTORY/sharp
zip -r $BUILD_ARTIFACTSTAGINGDIRECTORY/platform-update/sharp.zip *
popd
mv love/love.app love/Olympus.app
pushd love
mkdir $BUILD_ARTIFACTSTAGINGDIRECTORY/main
zip --symlinks -r $BUILD_ARTIFACTSTAGINGDIRECTORY/main/dist.zip *
popd
# Linux
- task: CmdLine@2
condition: and(succeeded(), eq(variables.agentArch, 'linux'))
displayName: 'Dist: Linux: Finish'
continueOnError: true
inputs:
script: |
cp olympus.sh love/$LOVEBINARYDIRECTORY/olympus
chmod a+rx love/$LOVEBINARYDIRECTORY/olympus
chmod a+rx love/$LOVEBINARYDIRECTORY/flatpak-wrapper
cp find-love.sh love/$LOVEBINARYDIRECTORY/find-love
chmod a+rx love/$LOVEBINARYDIRECTORY/find-love
chmod a+rx love/$LOVEBINARYDIRECTORY/love
chmod a+rx love/$LOVEBINARYDIRECTORY/install.sh
chmod a+rx love/$LOVEBINARYDIRECTORY/sharp/Olympus.Sharp
sed -i -e "s/BUILD_VERSION/$(Build.BuildNumber)/g" love/$LOVEBINARYDIRECTORY/io.github.everestapi.Olympus.metainfo.xml
sed -i -e "s/BUILD_DATE/$(date '+%Y-%m-%d')/g" love/$LOVEBINARYDIRECTORY/io.github.everestapi.Olympus.metainfo.xml
cp src/data/icon.png love/$LOVEBINARYDIRECTORY/olympus.png
rm love/$LOVEBINARYDIRECTORY/lib/x86_64-linux-gnu/libz.so.1
rm love/$LOVEBINARYDIRECTORY/usr/lib/x86_64-linux-gnu/libfreetype.so.6
rm love/$LOVEBINARYDIRECTORY/love.svg
rm love/$LOVEBINARYDIRECTORY/love.desktop.in
rm love/$LOVEBINARYDIRECTORY/license.txt
pushd love
mkdir $BUILD_ARTIFACTSTAGINGDIRECTORY/main
zip --symlinks -r $BUILD_ARTIFACTSTAGINGDIRECTORY/main/dist.zip *
popd
mkdir $BUILD_ARTIFACTSTAGINGDIRECTORY/platform-update
pushd love/sharp
zip -r $BUILD_ARTIFACTSTAGINGDIRECTORY/platform-update/sharp.zip *
popd
# Publish.
- task: PublishBuildArtifacts@1
condition: succeeded()
displayName: 'Dist: Publish main'
continueOnError: true
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/main'
artifactName: '$(artifactPrefix)main$(artifactSuffix)'
publishLocation: 'Container'
- task: PublishBuildArtifacts@1
condition: and(succeeded(), eq(variables.agentArch, 'windows'))
displayName: 'Dist: Publish update (common)'
continueOnError: true
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/update'
artifactName: 'update'
publishLocation: 'Container'
- task: PublishBuildArtifacts@1
displayName: 'Dist: Publish update (platform-specific)'
continueOnError: true
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/platform-update'
artifactName: '$(artifactPrefix)update$(artifactSuffix)'
publishLocation: 'Container'
- task: PublishBuildArtifacts@1
condition: and(succeeded(), eq(variables.agentArch, 'windows'))
displayName: 'Dist: Publish launcher-winforms'
continueOnError: true
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/launcher-winforms'
artifactName: 'launcher-winforms'
publishLocation: 'Container'