Skip to content

Commit bc2a41a

Browse files
committedJul 16, 2024
Update build info task
Differentiate Azure DevOps from GitHub Actions.
1 parent f494617 commit bc2a41a

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed
 

‎PowerShellEditorServices.build.ps1

+12-24
Original file line numberDiff line numberDiff line change
@@ -97,36 +97,24 @@ Task Clean FindDotNet, BinClean, {
9797
}
9898

9999
Task CreateBuildInfo {
100-
$buildVersion = "<development-build>"
101100
$buildOrigin = "Development"
102101
$buildCommit = git rev-parse HEAD
103102

104-
# Set build info fields on build platforms
105-
if ($env:TF_BUILD) {
106-
if ($env:BUILD_BUILDNUMBER -like "PR-*") {
107-
$buildOrigin = "PR"
108-
} elseif ($env:BUILD_DEFINITIONNAME -like "*-CI") {
109-
$buildOrigin = "CI"
110-
} else {
111-
$buildOrigin = "Release"
112-
}
103+
[xml]$xml = Get-Content "$PSScriptRoot/PowerShellEditorServices.Common.props"
104+
$buildVersion = $xml.Project.PropertyGroup.VersionPrefix
105+
$prerelease = $xml.Project.PropertyGroup.VersionSuffix
106+
if ($prerelease) { $buildVersion += "-$prerelease" }
113107

114-
$propsXml = [xml](Get-Content -Raw -LiteralPath "$PSScriptRoot/PowerShellEditorServices.Common.props")
115-
$propsBody = $propsXml.Project.PropertyGroup
116-
$buildVersion = $propsBody.VersionPrefix
117108

118-
if ($propsBody.VersionSuffix) {
119-
$buildVersion += '-' + $propsBody.VersionSuffix
109+
# Set build info fields on build platforms
110+
if ($env:TF_BUILD) { # Azure DevOps AKA OneBranch
111+
if ($env:BUILD_REASON -like "Manual") {
112+
$buildOrigin = "Release"
113+
} else {
114+
$buildOrigin = "AzureDevOps-CI"
120115
}
121-
}
122-
123-
# Allow override of build info fields (except date)
124-
if ($env:PSES_BUILD_VERSION) {
125-
$buildVersion = $env:PSES_BUILD_VERSION
126-
}
127-
128-
if ($env:PSES_BUILD_ORIGIN) {
129-
$buildOrigin = $env:PSES_BUILD_ORIGIN
116+
} elseif ($env:GITHUB_ACTIONS) {
117+
$buildOrigin = "GitHub-CI"
130118
}
131119

132120
[string]$buildTime = [datetime]::Today.ToString("s", [System.Globalization.CultureInfo]::InvariantCulture)

0 commit comments

Comments
 (0)
Please sign in to comment.