Skip to content

Commit e52a1b3

Browse files
Merge pull request #918 from brtsai/error-handler-log-build-version-and-type
Include branch name or PR number at the end of the version string
2 parents 98e51d1 + de09e37 commit e52a1b3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.azure-pipelines/prebuild.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
# Make the Everest version match the build number.
22
$BuildNumber = [string]([int]$env:BUILD_BUILDID + [int]$env:BUILD_BUILDIDOFFSET)
33
$EverestPath = [io.path]::combine($env:BUILD_SOURCESDIRECTORY, 'Celeste.Mod.mm', 'Mod', 'Everest', 'Everest.cs')
4-
(Get-Content $EverestPath) -replace '(?<=public readonly static string VersionString = ")[^"]*', "1.$BuildNumber.0-azure-$(($env:BUILD_SOURCEVERSION).Substring(0, 5))" | Set-Content $EverestPath
4+
# Get the branch name from Azure Pipelines
5+
if ($env:SYSTEM_PULLREQUEST_PULLREQUESTID -ne $null) {
6+
# Build triggered by a PR
7+
$BranchName = "pr$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
8+
} else {
9+
# Build triggered by a regular push
10+
$BranchName = $env:BUILD_SOURCEBRANCHNAME
11+
}
12+
# Compose the version string with branch info
13+
$SourceVersionShort = $env:BUILD_SOURCEVERSION.Substring(0, 5)
14+
$VersionString = "1.$BuildNumber.0-azure-$SourceVersionShort-$BranchName"
15+
16+
# Set Version String
17+
(Get-Content $EverestPath) -replace '(?<=public readonly static string VersionString = ")[^"]*', $VersionString | Set-Content $EverestPath
518

619
# Currently unstable/in development
720
$HelperPath = [io.path]::combine($env:BUILD_SOURCESDIRECTORY, 'Celeste.Mod.mm', 'Mod', 'Helpers', 'EverestVersion.cs')

0 commit comments

Comments
 (0)