Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lib-stripped artifact to build pipeline #372

Merged
merged 36 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
73923bd
Move azure build host from windows to ubuntu
coloursofnoise Aug 28, 2021
731deb9
Add lib-stripped artifact to build pipeline
coloursofnoise Aug 28, 2021
4c54837
fixup: succeded -> succeeded
coloursofnoise Aug 29, 2021
62f7da4
fixup: use Start-Process for miniinstaller.exe
coloursofnoise Aug 29, 2021
80404f1
fixup: remove (apparently now broken) reference
coloursofnoise Aug 29, 2021
577cb69
fixup: ...remove duplicate using
coloursofnoise Aug 29, 2021
19c4a23
fixup: remove some more usings
coloursofnoise Aug 29, 2021
4210d66
fixup: add explicit reference not included in powershell core
coloursofnoise Aug 29, 2021
c283fc7
fixup: different array syntax
coloursofnoise Aug 29, 2021
6bfe5a7
fixup: add more apparently missing references
coloursofnoise Aug 29, 2021
5bb7820
fixup: yet more references
coloursofnoise Aug 29, 2021
219a98b
Attempt to remove EverestPS file entirely
coloursofnoise Aug 29, 2021
9c51aaf
Capitalize envvars just in case
coloursofnoise Aug 29, 2021
77a0eb7
fixup: add ending slash to Start-Process WorkingDirectory
coloursofnoise Aug 29, 2021
23bf346
fixup: tweak Start-Process some more
coloursofnoise Aug 30, 2021
d873afc
fixup: remove ending slash from build folder var
coloursofnoise Aug 30, 2021
5152cfd
fixup: use mono to run Miniinstaller.exe
coloursofnoise Aug 30, 2021
9139bc8
fixup: remove a dash
coloursofnoise Aug 30, 2021
28cbef4
fixup: remove quotes from bare envvars
coloursofnoise Aug 30, 2021
0fe1415
fixup: log LIB_STRIPPED variable, remove WorkingDirectory arg
coloursofnoise Aug 30, 2021
22d25e6
fixup: create folders before use
coloursofnoise Aug 30, 2021
5db630d
fixup: full file path and wait for process
coloursofnoise Aug 30, 2021
4541b4f
fixup: flatten build directory when copying
coloursofnoise Aug 30, 2021
b7deb5b
fixup: add debug logging
coloursofnoise Aug 30, 2021
272b7a4
Switch from Steam DepotDownloader to self-hosted
coloursofnoise Sep 2, 2021
f39a82d
fixup: store bin url in variable
coloursofnoise Sep 2, 2021
1fafd44
fixup: hardcode bin url
coloursofnoise Sep 2, 2021
5298698
fixup: revert hardcode bin url
coloursofnoise Sep 2, 2021
3b25ccb
fixup: nest envvar access
coloursofnoise Sep 2, 2021
0628abc
Skip stripped lib step for PRs
coloursofnoise Sep 3, 2021
405e4d5
fixup: add quotes to yaml variable reference
coloursofnoise Sep 3, 2021
3dfefe7
fixup: quote powershell variable reference
coloursofnoise Sep 3, 2021
e17e2d0
attempt to log BIN_URL secret for debugging
coloursofnoise Sep 5, 2021
96b0d94
fixup: add test case for unassigned envvar
coloursofnoise Sep 5, 2021
3ed15f9
fixup: attempt to fix variable evaluation
coloursofnoise Sep 5, 2021
bbb9f74
fixup: fix typo
coloursofnoise Sep 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions azure-pipelines-ext.cs

This file was deleted.

46 changes: 41 additions & 5 deletions azure-pipelines-postbuild.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Add-Type -AssemblyName System.IO.Compression.FileSystem
Add-Type -Path "azure-pipelines-ext.cs" -ReferencedAssemblies "System.IO.Compression.FileSystem"

$OLYMPUS="$env:Build_ArtifactStagingDirectory/olympus/"
$OLYMPUS="$env:BUILD_ARTIFACTSTAGINGDIRECTORY/olympus/"
if ($OLYMPUS -eq "/olympus/") {
$OLYMPUS = "./tmp-olympus/"
}
Expand All @@ -15,9 +14,46 @@ New-Item -ItemType "directory" -Path $OLYMPUS/meta
New-Item -ItemType "directory" -Path $OLYMPUS/build

Write-Output "Building Olympus build artifact"
# Azure Pipelines apparently hates to write to the artifact staging dir directly.
[EverestPS]::Zip("$env:Build_ArtifactStagingDirectory/main", "olympus-build.zip")
Move-Item -Path "olympus-build.zip" -Destination $ZIP
$compress = @{
Path = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/main"
CompressionLevel = "Optimal"
DestinationPath = "$ZIP"
}
Compress-Archive @compress

Write-Output "Building Olympus metadata artifact"
Write-Output (Get-Item -Path $ZIP).length | Out-File -FilePath $OLYMPUS/meta/size.txt

# lib-stripped setup
if ([string]::IsNullOrEmpty("$env:BIN_URL") -or ($env:BIN_URL -eq '$(BIN_URL)')) {
Write-Output "Skipping lib-stripped artifact"
Exit 0
}

$LIB_STRIPPED="$env:BUILD_ARTIFACTSTAGINGDIRECTORY/lib-stripped"
if ($LIB_STRIPPED -eq "/lib-stripped") {
$LIB_STRIPPED = "./tmp-lib-stripped"
}

Write-Output "Creating lib-stripped artifact directories"
Remove-Item -ErrorAction Ignore -Recurse -Force -Path $LIB_STRIPPED
New-Item -ItemType "directory" -Path $LIB_STRIPPED
New-Item -ItemType "directory" -Path $LIB_STRIPPED/build

Write-Output "Downloading Celeste package"
$creds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($env:BIN_USERNAME):$($env:BIN_PASSWORD)"))
$headers = @{'Authorization'= "Basic $creds"}
Invoke-WebRequest -URI "$env:BIN_URL/Celeste_Linux.zip" -OutFile "$env:AGENT_TEMPDIRECTORY/Celeste.zip" -Headers $headers
Expand-Archive -Path "$env:AGENT_TEMPDIRECTORY/Celeste.zip" -DestinationPath $LIB_STRIPPED

Write-Output "Applying Everest patch"
Copy-Item -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/main/*" -Destination $LIB_STRIPPED
Start-Process -FilePath "mono" -ArgumentList "$LIB_STRIPPED/MiniInstaller.exe" -WorkingDirectory $LIB_STRIPPED -Wait

Write-Output "Generating stripped files"
$files = Get-ChildItem -Path "$LIB_STRIPPED/*" -Include *.dll,*.exe
foreach ($dll in $files) {
mono-cil-strip -q $dll
}
Copy-Item $files -Destination "$LIB_STRIPPED/build"
Write-Host "##vso[task.setvariable variable=lib_stripped]True"
21 changes: 18 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

pool:
vmImage: 'windows-latest'
vmImage: 'ubuntu-latest'

variables:
solution: '**/*.sln'
Expand Down Expand Up @@ -54,10 +54,15 @@ steps:

# Post-build steps.
- task: PowerShell@2
name: PostBuild
condition: succeeded()
displayName: 'Run azure-pipelines-postbuild.ps1'
inputs:
filePath: 'azure-pipelines-postbuild.ps1'
env:
BIN_URL: $(BIN_URL)
BIN_USERNAME: $(BIN_USERNAME)
BIN_PASSWORD: $(BIN_PASSWORD)

# Create and "publish" Olympus artifacts.
- task: PublishBuildArtifacts@1
Expand All @@ -77,9 +82,19 @@ steps:
artifactName: 'olympus-build'
publishLocation: 'Container'

# Create and "publish" mono-cil-strip binary artifacts
- task: PublishBuildArtifacts@1
condition: eq(variables['PostBuild.lib_stripped'], 'True')
displayName: 'Publish lib-stripped artifact'
continueOnError: true
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/lib-stripped/build/'
artifactName: 'lib-stripped'
publishLocation: 'Container'

# Announce new stable versions on Discord (#modding_updates).
- script: |
set /a "BUILD_NUMBER=$(Build.BuildId)+$(Build.BuildIdOffset)"
curl -H "Content-Type: application/json" -d "{\"content\": \"**A new Everest stable was just released!**\nThe latest stable version is now **%BUILD_NUMBER%**.\"}" $(WEBHOOK_URL)
declare -i BUILD_NUMBER=$(Build.BuildId)+$(Build.BuildIdOffset)
curl -H "Content-Type: application/json" -d "{\"content\": \"**A new Everest stable was just released!**\nThe latest stable version is now **$BUILD_NUMBER**.\"}" $(WEBHOOK_URL)
displayName: 'Celeste Discord webhook'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/stable'))