Skip to content

Commit

Permalink
Base build name off the source branch and implement a derivative of C…
Browse files Browse the repository at this point in the history
…alVer
  • Loading branch information
jrbriggs committed Aug 15, 2019
1 parent 3867bf3 commit 707eda9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
10 changes: 5 additions & 5 deletions .azure-pipelines/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: $(date:yy)$(DayOfYear)$(rev:.r)

trigger:
- master
- releases/shipped
Expand All @@ -11,9 +9,7 @@ pr:
- servicing/*

variables:
majorAndMinorVersion: '0.4'
revision: '$(Build.BuildNumber)'
platform: 'x64'
branchCounter: $[counter(variables['Build.SourceBranch'], 0)]

jobs:
- job: Windows_Build_and_UnitTests
Expand All @@ -29,6 +25,8 @@ jobs:
pool:
vmImage: vs2017-win2016
steps:
- powershell: $(Build.Repository.LocalPath)/Scripts/CI/Set-Version.ps1 -SourceBranchCounter $(branchCounter)
displayName: "Compute product version"
- template: templates/windows-build-and-unit-test.yml

- job: macOS_Build_and_UnitTests
Expand All @@ -44,6 +42,8 @@ jobs:
pool:
name: 'Hosted macOS'
steps:
- powershell: $(Build.Repository.LocalPath)/Scripts/CI/Set-Version.ps1 -SourceBranchCounter $(branchCounter)
displayName: "Compute product version"
- template: templates/macos-build-and-unit-test.yml

- job: macOS_FunctionalTests
Expand Down
2 changes: 1 addition & 1 deletion .azure-pipelines/templates/macos-build-and-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ steps:
certSecureFile: 'PrjFSKextCertExpiresJun6_2020_v2.p12'
certPwd: '$(kext.certificate.password)'

- script: Scripts/Mac/BuildScalarForMac.sh $(configuration)
- script: Scripts/Mac/BuildScalarForMac.sh $(configuration) $(majorAndMinorVersion).$(revision)
displayName: Build Scalar ($(configuration))

- task: PublishTestResults@2
Expand Down
47 changes: 47 additions & 0 deletions Scripts/CI/Set-Version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<#
Generates the pipeline variables for the product version and set the build number.
#>
param (
[Parameter(Mandatory)]
[string]$SourceBranchCounter # should always be set to counter($(Build.SourceBranch), 0)
)

function Set-PipelineVariable {
Param ([string]$VarName, [string]$VarValue)
Write-Host "##vso[task.setvariable variable=$VarName;]$VarValue"
}

function Set-BuildNumber {
Param([string]$BuildNumber)
Write-Host "##vso[build.updatebuildnumber]$BuildNumber"
}

$SourceBranch = $Env:BUILD_SOURCEBRANCH
$SourceBranchName = $Env:BUILD_SOURCEBRANCHNAME

$ReleaseBranch = 'refs/heads/releases/(?<Year>\d{2})\.(?<Month>\d{2})\.(?<Milestone>\d{3})'
$PullRequest = 'refs/pull/(?<PrNum>\d+)/merge'

$Major = 0
$Minor = 0
$Revision = 0

if ($SourceBranch -match $ReleaseBranch) {
$Major = $Matches["Year"]
$Minor = $Matches["Month"]
$Revision = $Matches["Milestone"]
Set-BuildNumber "Release-$Major.$Minor.$Revision.$SourceBranchCounter"
} elseif ($SourceBranch -match $PullRequest) {
$Major = 10
$Minor = 20
$Revision = $Matches["PrNum"]
Set-BuildNumber "PR-$Revision.$SourceBranchCounter"
} else { # Typical CI scenario. Handles tags and non-release branches.
$Major = (Get-Date -Format yy)
$Minor = (Get-Date -Format MM)
$Revision = (Get-Date -Format dd)
Set-BuildNumber "CI-$SourceBranchName.$SourceBranchCounter"
}

Set-PipelineVariable "majorAndMinorVersion" "$Major.$Minor"
Set-PipelineVariable "revision" "$Revision.$SourceBranchCounter"

0 comments on commit 707eda9

Please sign in to comment.