Skip to content

Commit

Permalink
Update build info task
Browse files Browse the repository at this point in the history
Differentiate Azure DevOps from GitHub Actions.
  • Loading branch information
andyleejordan committed Jul 16, 2024
1 parent f494617 commit bc2a41a
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,36 +97,24 @@ Task Clean FindDotNet, BinClean, {
}

Task CreateBuildInfo {
$buildVersion = "<development-build>"
$buildOrigin = "Development"
$buildCommit = git rev-parse HEAD

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

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

if ($propsBody.VersionSuffix) {
$buildVersion += '-' + $propsBody.VersionSuffix
# Set build info fields on build platforms
if ($env:TF_BUILD) { # Azure DevOps AKA OneBranch
if ($env:BUILD_REASON -like "Manual") {
$buildOrigin = "Release"
} else {
$buildOrigin = "AzureDevOps-CI"
}
}

# Allow override of build info fields (except date)
if ($env:PSES_BUILD_VERSION) {
$buildVersion = $env:PSES_BUILD_VERSION
}

if ($env:PSES_BUILD_ORIGIN) {
$buildOrigin = $env:PSES_BUILD_ORIGIN
} elseif ($env:GITHUB_ACTIONS) {
$buildOrigin = "GitHub-CI"
}

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

0 comments on commit bc2a41a

Please sign in to comment.