Skip to content

Commit c9f4a82

Browse files
authored
Merge pull request #222 from petrsnd/chore/modernize-pipeline
Modernize pipeline: trunk-based dev, tag releases, GitHub Releases
2 parents 0b4ca0f + e6566cc commit c9f4a82

5 files changed

Lines changed: 74 additions & 17 deletions

File tree

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Require review from SafeguardPasswords team for all changes
2+
* @OneIdentity/SafeguardPasswords

build.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,31 @@ variables:
44
trigger:
55
branches:
66
include:
7+
- main
78
- master
89
- release-*
10+
tags:
11+
include:
12+
- 'v*'
913
paths:
1014
exclude:
11-
- README.md
12-
- AGENTS.md
15+
- '**/*.md'
16+
- LICENSE
17+
- docs/
18+
- .github/CODEOWNERS
1319

1420
pr:
1521
branches:
1622
include:
23+
- main
1724
- master
1825
- release-*
1926
paths:
2027
exclude:
21-
- README.md
22-
- AGENTS.md
28+
- '**/*.md'
29+
- LICENSE
30+
- docs/
31+
- .github/CODEOWNERS
2332

2433
jobs:
2534
# Job 1: PR Validation - runs only on pull requests
@@ -121,3 +130,20 @@ jobs:
121130
command: 'custom'
122131
arguments: 'push $(Build.ArtifactStagingDirectory)\*.nupkg -source https://api.nuget.org/v3/index.json -ApiKey $(NugetOrgApiKey) -NonInteractive -Verbosity detailed'
123132
displayName: 'Publishing NuGet packages to NuGet.org'
133+
134+
- task: GitHubRelease@1
135+
inputs:
136+
gitHubConnection: 'PangaeaBuild-GitHub'
137+
repositoryName: 'OneIdentity/SafeguardDotNet'
138+
action: 'create'
139+
target: '$(Build.SourceVersion)'
140+
tagSource: 'userSpecifiedTag'
141+
tag: '$(ReleaseTag)'
142+
title: '$(ReleaseTag)'
143+
isPreRelease: $(isPrerelease)
144+
changeLogCompareToRelease: 'lastFullRelease'
145+
changeLogType: 'commitBased'
146+
assets: |
147+
$(Build.ArtifactStagingDirectory)/*.nupkg
148+
$(Build.ArtifactStagingDirectory)/*.snupkg
149+
displayName: 'Creating GitHub Release'

pipeline-templates/build-steps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ steps:
22
- task: PowerShell@2
33
inputs:
44
targetType: filePath
5-
filePath: $(System.DefaultWorkingDirectory)\versionnumber.ps1
6-
arguments: $(Build.SourcesDirectory) $(semanticVersion) $(Build.BuildId) $$(isPrerelease)
5+
filePath: $(System.DefaultWorkingDirectory)\pipeline-templates\versionnumber.ps1
6+
arguments: $(Build.SourcesDirectory) $(semanticVersion) $(Build.BuildId) $$(isPrerelease) $(Build.SourceBranchName) $(isTagBuild)
77
displayName: 'Setting build version'
88

99
- task: Bash@3
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
variables:
22
- name: semanticVersion
33
value: '8.2.3'
4+
- name: isTagBuild
5+
value: ${{ startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}
46
- name: isPrerelease
5-
value: ${{ true }}
7+
${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}:
8+
value: false
9+
${{ else }}:
10+
value: true
Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ Param(
77
[Parameter(Mandatory=$true, Position=2)]
88
[string]$BuildId,
99
[Parameter(Mandatory=$true, Position=3)]
10-
[bool]$IsPrerelease
10+
[bool]$IsPrerelease,
11+
[Parameter(Mandatory=$false, Position=4)]
12+
[string]$TagName = "",
13+
[Parameter(Mandatory=$false, Position=5)]
14+
[string]$IsTagBuild = "False"
1115
)
1216

17+
$local:IsTagBuildBool = $IsTagBuild -eq "True"
18+
1319
Write-Host "SemanticVersion = $SemanticVersion"
1420
Write-Host "BuildId = $BuildId"
21+
Write-Host "TagName = $TagName"
22+
Write-Host "IsTagBuild = $IsTagBuild"
1523

1624
# Build number must be between 0 - 65534
1725
$local:BuildNumber = $BuildId % 65534
@@ -20,41 +28,57 @@ Write-Host "BuildNumber = $($local:BuildNumber)"
2028

2129
$local:PackageCodeMarker = "9999.9999.9999"
2230
$local:AssemblyCodeMarker = "9999.9999.9999.9999"
23-
$local:AssemblyVersion = "${SemanticVersion}.$($local:BuildNumber)"
24-
if ($IsPrerelease)
31+
32+
if ($local:IsTagBuildBool)
2533
{
26-
$local:PackageVersion = "${SemanticVersion}-dev-$($local:BuildNumber)"
34+
# Validate tag format
35+
if ($TagName -notmatch '^v\d+\.\d+\.\d+$')
36+
{
37+
Write-Error "ERROR: Tag '$TagName' does not match expected format 'v<major>.<minor>.<patch>'. Aborting release build."
38+
exit 1
39+
}
40+
$local:TagVersion = $TagName -replace '^v', ''
41+
$local:PackageVersion = $local:TagVersion
42+
$local:AssemblyVersion = "${local:TagVersion}.$($local:BuildNumber)"
43+
$local:ReleaseTag = $TagName
44+
Write-Host "Tag build detected, using tag name as version"
2745
}
2846
else
2947
{
30-
$local:PackageVersion = $SemanticVersion
48+
$local:AssemblyVersion = "${SemanticVersion}.$($local:BuildNumber)"
49+
$local:PackageVersion = "${SemanticVersion}-pre$($local:BuildNumber)"
50+
$local:ReleaseTag = "dev/v$($local:PackageVersion)"
51+
Write-Host "Dev build"
3152
}
3253
Write-Host "PackageCodeMarker = $($local:PackageCodeMarker)"
3354
Write-Host "AssemblyCodeMarker = $($local:AssemblyCodeMarker)"
3455
Write-Host "PackageVersion = $($local:PackageVersion)"
3556
Write-Host "AssemblyVersion = $($local:AssemblyVersion)"
3657

58+
$local:RepoRoot = $SourceDir
59+
3760
Write-Host "Replacing markers in SafeguardDotNet"
38-
$local:ProjectFile = (Join-Path $PSScriptRoot "SafeguardDotNet\SafeguardDotNet.csproj")
61+
$local:ProjectFile = (Join-Path $local:RepoRoot "SafeguardDotNet\SafeguardDotNet.csproj")
3962
(Get-Content $local:ProjectFile -Raw).replace($local:AssemblyCodeMarker, $local:AssemblyVersion).TrimEnd() | Set-Content -Encoding UTF8 $local:ProjectFile
4063
(Get-Content $local:ProjectFile -Raw).replace($local:PackageCodeMarker, $local:PackageVersion).TrimEnd() | Set-Content -Encoding UTF8 $local:ProjectFile
4164

4265
Write-Host "Replacing markers in SafeguardDotNet.BrowserLogin"
43-
$local:ProjectFile = (Join-Path $PSScriptRoot "SafeguardDotNet.BrowserLogin\SafeguardDotNet.BrowserLogin.csproj")
66+
$local:ProjectFile = (Join-Path $local:RepoRoot "SafeguardDotNet.BrowserLogin\SafeguardDotNet.BrowserLogin.csproj")
4467
(Get-Content $local:ProjectFile -Raw).replace($local:AssemblyCodeMarker, $local:AssemblyVersion).TrimEnd() | Set-Content -Encoding UTF8 $local:ProjectFile
4568
(Get-Content $local:ProjectFile -Raw).replace($local:PackageCodeMarker, $local:PackageVersion).TrimEnd() | Set-Content -Encoding UTF8 $local:ProjectFile
4669

4770
Write-Host "Replacing markers in SafeguardDotNet.PkceNoninteractiveLogin"
48-
$local:ProjectFile = (Join-Path $PSScriptRoot "SafeguardDotNet.PkceNoninteractiveLogin\SafeguardDotNet.PkceNoninteractiveLogin.csproj")
71+
$local:ProjectFile = (Join-Path $local:RepoRoot "SafeguardDotNet.PkceNoninteractiveLogin\SafeguardDotNet.PkceNoninteractiveLogin.csproj")
4972
(Get-Content $local:ProjectFile -Raw).replace($local:AssemblyCodeMarker, $local:AssemblyVersion).TrimEnd() | Set-Content -Encoding UTF8 $local:ProjectFile
5073
(Get-Content $local:ProjectFile -Raw).replace($local:PackageCodeMarker, $local:PackageVersion).TrimEnd() | Set-Content -Encoding UTF8 $local:ProjectFile
5174

5275
Write-Host "Replacing markers in SafeguardDotNet.GuiLogin"
53-
$local:GuiAssemblyInfoFile = (Join-Path $PSScriptRoot "SafeguardDotNet.GuiLogin\Properties\AssemblyInfo.cs")
54-
$local:GuiNuspec = (Join-Path $PSScriptRoot "SafeguardDotNet.GuiLogin\SafeguardDotNet.GuiLogin.nuspec")
76+
$local:GuiAssemblyInfoFile = (Join-Path $local:RepoRoot "SafeguardDotNet.GuiLogin\Properties\AssemblyInfo.cs")
77+
$local:GuiNuspec = (Join-Path $local:RepoRoot "SafeguardDotNet.GuiLogin\SafeguardDotNet.GuiLogin.nuspec")
5578
(Get-Content $local:GuiAssemblyInfoFile -Raw).replace($local:AssemblyCodeMarker, $local:AssemblyVersion).TrimEnd() | Set-Content -Encoding UTF8 $local:GuiAssemblyInfoFile
5679
(Get-Content $local:GuiNuspec -Raw).replace($local:PackageCodeMarker, $local:PackageVersion).TrimEnd() | Set-Content -Encoding UTF8 $local:GuiNuspec
5780

5881

5982
Write-Output "##vso[task.setvariable variable=AssemblyVersion;]$($local:AssemblyVersion)"
6083
Write-Output "##vso[task.setvariable variable=PackageVersion;]$($local:PackageVersion)"
84+
Write-Output "##vso[task.setvariable variable=ReleaseTag;]$($local:ReleaseTag)"

0 commit comments

Comments
 (0)