Skip to content

Commit

Permalink
Merge pull request #372 from coloursofnoise/lib-stripped
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0ade authored Sep 28, 2021
2 parents 56b1ecf + bbb9f74 commit 88ffe01
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 42 deletions.
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'))

0 comments on commit 88ffe01

Please sign in to comment.