Skip to content

Commit 5efa21e

Browse files
TravisEz13Copilot
andauthored
[release/v7.4] Add rebuild branch support with conditional MSIX signing (#26418)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d0ae31b commit 5efa21e

9 files changed

Lines changed: 127 additions & 21 deletions

File tree

.pipelines/EV2Specs/ServiceGroupRoot/Shell/Run/Run.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ try {
354354
$skipPublish = $metadataContent.SkipPublish
355355
$lts = $metadataContent.LTS
356356

357+
# Check if this is a rebuild version (e.g., 7.4.13-rebuild.5)
358+
$isRebuild = $releaseVersion -match '-rebuild\.'
359+
357360
if ($releaseVersion.Contains('-')) {
358361
$channel = 'preview'
359362
$packageNames = @('powershell-preview')
@@ -363,7 +366,8 @@ try {
363366
$packageNames = @('powershell')
364367
}
365368

366-
if ($lts) {
369+
# Only add LTS package if not a rebuild branch
370+
if ($lts -and -not $isRebuild) {
367371
$packageNames += @('powershell-lts')
368372
}
369373

.pipelines/PowerShell-Coordinated_Packages-Official.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,20 @@ extends:
281281
- template: /.pipelines/templates/SetVersionVariables.yml@self
282282
parameters:
283283
ReleaseTagVar: $(ReleaseTagVar)
284+
- template: /.pipelines/templates/rebuild-branch-check.yml@self
284285
- powershell: |
285286
$metadata = Get-Content '$(Build.SourcesDirectory)/PowerShell/tools/metadata.json' -Raw | ConvertFrom-Json
286-
$LTS = $metadata.LTSRelease.Package
287+
288+
# Use the rebuild branch check from the template
289+
$isRebuildBranch = '$(RebuildBranchCheck.IsRebuildBranch)' -eq 'true'
290+
291+
# Don't mark as LTS release for rebuild branches
292+
$LTS = $metadata.LTSRelease.Package -and -not $isRebuildBranch
293+
294+
if ($isRebuildBranch) {
295+
Write-Verbose -Message "Rebuild branch detected, not marking as LTS release" -Verbose
296+
}
297+
287298
@{ ReleaseVersion = "$(Version)"; LTSRelease = $LTS } | ConvertTo-Json | Out-File "$(Build.StagingDirectory)\release.json"
288299
Get-Content "$(Build.StagingDirectory)\release.json"
289300

.pipelines/PowerShell-Packages-Official.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ extends:
293293
dependsOn: [windows_package_build] # Only depends on unsigned packages
294294
jobs:
295295
- template: /.pipelines/templates/package-create-msix.yml@self
296+
parameters:
297+
OfficialBuild: ${{ parameters.OfficialBuild }}
296298

297299
- stage: upload
298300
displayName: 'Upload'

.pipelines/templates/channelSelection.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,31 @@ steps:
22
- pwsh: |
33
# Determine LTS, Preview, or Stable
44
$metadata = Get-Content "$(Build.SourcesDirectory)/PowerShell/tools/metadata.json" -Raw | ConvertFrom-Json
5+
$releaseTag = '$(OutputReleaseTag.releaseTag)'
6+
7+
# Rebuild branches should be treated as preview builds
8+
# NOTE: The following regex is duplicated from rebuild-branch-check.yml.
9+
# This duplication is necessary because channelSelection.yml does not call rebuild-branch-check.yml,
10+
# and is used in contexts where that check may not have run.
11+
# If you update this regex, also update it in rebuild-branch-check.yml to keep them in sync.
12+
$isRebuildBranch = '$(Build.SourceBranch)' -match 'refs/heads/rebuild/.*-rebuild\.'
13+
514
$LTS = $metadata.LTSRelease.Latest
615
$Stable = $metadata.StableRelease.Latest
7-
$isPreview = '$(OutputReleaseTag.releaseTag)' -match '-'
16+
$isPreview = $releaseTag -match '-'
817
9-
$IsLTS = [bool]$LTS
10-
$IsStable = [bool]$Stable
11-
$IsPreview = [bool]$isPreview
18+
# If this is a rebuild branch, force preview mode and ignore LTS metadata
19+
if ($isRebuildBranch) {
20+
$IsLTS = $false
21+
$IsStable = $false
22+
$IsPreview = $true
23+
Write-Verbose -Message "Rebuild branch detected, forcing Preview channel" -Verbose
24+
}
25+
else {
26+
$IsLTS = [bool]$LTS
27+
$IsStable = [bool]$Stable
28+
$IsPreview = [bool]$isPreview
29+
}
1230
1331
$channelVars = @{
1432
IsLTS = $IsLTS

.pipelines/templates/linux-package-build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ jobs:
6262
parameters:
6363
nativePathRoot: '$(Agent.TempDirectory)'
6464

65+
- template: rebuild-branch-check.yml@self
66+
6567
- download: CoOrdinatedBuildPipeline
6668
artifact: ${{ parameters.unsignedDrop }}
6769
displayName: 'Download unsigned artifacts'
@@ -143,7 +145,15 @@ jobs:
143145
Write-Verbose -Verbose "metadata:"
144146
$metadata | Out-String | Write-Verbose -Verbose
145147
146-
$LTS = $metadata.LTSRelease.Package -eq 'True'
148+
# Use the rebuild branch check from the template
149+
$isRebuildBranch = '$(RebuildBranchCheck.IsRebuildBranch)' -eq 'true'
150+
151+
# Don't build LTS packages for rebuild branches
152+
$LTS = $metadata.LTSRelease.Package -and -not $isRebuildBranch
153+
154+
if ($isRebuildBranch) {
155+
Write-Verbose -Message "Rebuild branch detected, skipping LTS package build" -Verbose
156+
}
147157
148158
Write-Verbose -Verbose "LTS: $LTS"
149159

.pipelines/templates/mac-package-build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
parameters:
6161
nativePathRoot: '$(Agent.TempDirectory)'
6262

63+
- template: rebuild-branch-check.yml@self
64+
6365
- download: CoOrdinatedBuildPipeline
6466
artifact: macosBinResults-${{ parameters.buildArchitecture }}
6567

@@ -111,7 +113,15 @@ jobs:
111113
Write-Verbose -Verbose "metadata:"
112114
$metadata | Out-String | Write-Verbose -Verbose
113115
114-
$LTS = $metadata.LTSRelease.Package -eq 'True'
116+
# Use the rebuild branch check from the template
117+
$isRebuildBranch = '$(RebuildBranchCheck.IsRebuildBranch)' -eq 'true'
118+
119+
# Don't build LTS packages for rebuild branches
120+
$LTS = $metadata.LTSRelease.Package -and -not $isRebuildBranch
121+
122+
if ($isRebuildBranch) {
123+
Write-Verbose -Message "Rebuild branch detected, skipping LTS package build" -Verbose
124+
}
115125
116126
Write-Verbose -Verbose "LTS: $LTS"
117127

.pipelines/templates/package-create-msix.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
parameters:
2+
- name: OfficialBuild
3+
type: boolean
4+
default: false
5+
16
jobs:
27
- job: CreateMSIXBundle
38
displayName: Create .msixbundle file
@@ -49,7 +54,7 @@ jobs:
4954
**/*.msix
5055
targetPath: '$(Build.ArtifactStagingDirectory)/downloads'
5156
displayName: Download windows x86 packages
52-
57+
5358
# Finds the makeappx tool on the machine with image: 'onebranch.azurecr.io/windows/ltsc2022/vse2022:latest'
5459
- pwsh: |
5560
$cmd = Get-Command makeappx.exe -ErrorAction Ignore
@@ -99,12 +104,13 @@ jobs:
99104
100105
- task: onebranch.pipeline.signing@1
101106
displayName: Sign MsixBundle
107+
condition: eq('${{ parameters.OfficialBuild }}', 'true')
102108
inputs:
103109
command: 'sign'
104110
signing_profile: $(MSIXProfile)
105111
files_to_sign: '**/*.msixbundle'
106112
search_root: '$(BundleDir)'
107-
113+
108114
- pwsh: |
109115
$signedBundle = Get-ChildItem -Path $(BundleDir) -Filter "*.msixbundle" -File
110116
Write-Verbose -Verbose "Signed bundle: $signedBundle"
@@ -126,12 +132,12 @@ jobs:
126132
Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Recurse | Select-Object -ExpandProperty FullName
127133
Test-Path -Path '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/PDP-Private.xml' | Write-Verbose -Verbose
128134
displayName: Output Pipeline.Workspace and System.DefaultWorkingDirectory
129-
135+
130136
- template: channelSelection.yml@self
131137

132138
- pwsh: |
133139
$IsLTS = '$(ChannelSelection.IsLTS)' -eq 'true'
134-
$IsStable = '$(ChannelSelection.IsStable)' -eq 'true'
140+
$IsStable = '$(ChannelSelection.IsStable)' -eq 'true'
135141
$IsPreview = '$(ChannelSelection.IsPreview)' -eq 'true'
136142
137143
Write-Verbose -Verbose "Channel Selection - LTS: $IsLTS, Stable: $IsStable, Preview: $IsPreview"
@@ -161,11 +167,11 @@ jobs:
161167
$currentChannel = if ($IsLTS) { 'LTS' }
162168
elseif ($IsStable) { 'Stable' }
163169
elseif ($IsPreview) { 'Preview' }
164-
else {
170+
else {
165171
Write-Error "No valid channel detected"
166172
exit 1
167173
}
168-
174+
169175
$config = $channelConfigs[$currentChannel]
170176
Write-Verbose -Verbose "Selected channel: $currentChannel"
171177
Write-Verbose -Verbose "App Store Name: $($config.AppStoreName)"
@@ -181,7 +187,7 @@ jobs:
181187
# Create namespace manager for XML with default namespace
182188
$nsManager = New-Object System.Xml.XmlNamespaceManager($pdpXml.NameTable)
183189
$nsManager.AddNamespace("pd", "http://schemas.microsoft.com/appx/2012/ProductDescription")
184-
190+
185191
$appStoreNameElement = $pdpXml.SelectSingleNode("//pd:AppStoreName", $nsManager)
186192
if ($appStoreNameElement) {
187193
$appStoreNameElement.SetAttribute("_locID", $config.AppStoreName)
@@ -220,12 +226,30 @@ jobs:
220226
Write-Host "##vso[task.setvariable variable=SBConfigPath]$($sbConfigPath)"
221227
222228
# These variables are used in the next tasks to determine which ServiceEndpoint to use
223-
Write-Host "##vso[task.setvariable variable=LTS]$($IsLTS.ToString().ToLower())"
224-
Write-Host "##vso[task.setvariable variable=STABLE]$($IsStable.ToString().ToLower())"
225-
Write-Host "##vso[task.setvariable variable=PREVIEW]$($IsPreview.ToString().ToLower())"
229+
$ltsValue = $IsLTS.ToString().ToLower()
230+
$stableValue = $IsStable.ToString().ToLower()
231+
$previewValue = $IsPreview.ToString().ToLower()
232+
233+
Write-Verbose -Verbose "About to set variables:"
234+
Write-Verbose -Verbose " LTS=$ltsValue"
235+
Write-Verbose -Verbose " STABLE=$stableValue"
236+
Write-Verbose -Verbose " PREVIEW=$previewValue"
237+
238+
Write-Host "##vso[task.setvariable variable=LTS]$ltsValue"
239+
Write-Host "##vso[task.setvariable variable=STABLE]$stableValue"
240+
Write-Host "##vso[task.setvariable variable=PREVIEW]$previewValue"
241+
242+
Write-Verbose -Verbose "Variables set successfully"
226243
name: UpdateConfigs
227244
displayName: Update PDPs and SBConfig.json
228245
246+
- pwsh: |
247+
Write-Verbose -Verbose "Checking variables after UpdateConfigs:"
248+
Write-Verbose -Verbose "LTS=$(LTS)"
249+
Write-Verbose -Verbose "STABLE=$(STABLE)"
250+
Write-Verbose -Verbose "PREVIEW=$(PREVIEW)"
251+
displayName: Debug - Check Variables
252+
229253
- task: MS-RDX-MRO.windows-store-publish.package-task.store-package@3
230254
displayName: 'Create StoreBroker Package (Preview)'
231255
condition: eq('$(PREVIEW)', 'true')
@@ -260,14 +284,14 @@ jobs:
260284
$submissionPackageDir = "$(System.DefaultWorkingDirectory)/SBOutDir"
261285
$jsonFile = "$submissionPackageDir/PowerShellStorePackage.json"
262286
$zipFile = "$submissionPackageDir/PowerShellStorePackage.zip"
263-
287+
264288
if ((Test-Path $jsonFile) -and (Test-Path $zipFile)) {
265289
Write-Verbose -Verbose "Uploading StoreBroker Package files:"
266290
Write-Verbose -Verbose "JSON File: $jsonFile"
267291
Write-Verbose -Verbose "ZIP File: $zipFile"
268292
269293
Copy-Item -Path $submissionPackageDir -Destination "$(ob_outputDirectory)" -Verbose -Recurse
270-
}
294+
}
271295
272296
else {
273297
Write-Error "Required files not found in $submissionPackageDir"

.pipelines/templates/packaging/windows/package.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
nativePathRoot: '$(Agent.TempDirectory)'
6161
ob_restore_phase: false
6262

63+
- template: rebuild-branch-check.yml@self
64+
6365
- download: CoOrdinatedBuildPipeline
6466
artifact: drop_windows_build_windows_${{ parameters.runtime }}_release
6567
displayName: Download signed artifacts
@@ -135,7 +137,15 @@ jobs:
135137
Write-Verbose -Verbose "metadata:"
136138
$metadata | Out-String | Write-Verbose -Verbose
137139
138-
$LTS = $metadata.LTSRelease.Package -eq 'True'
140+
# Use the rebuild branch check from the template
141+
$isRebuildBranch = '$(RebuildBranchCheck.IsRebuildBranch)' -eq 'true'
142+
143+
# Don't build LTS packages for rebuild branches
144+
$LTS = $metadata.LTSRelease.Package -and -not $isRebuildBranch
145+
146+
if ($isRebuildBranch) {
147+
Write-Verbose -Message "Rebuild branch detected, skipping LTS package build" -Verbose
148+
}
139149
140150
Write-Verbose -Verbose "LTS: $LTS"
141151
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This template checks if the current branch is a rebuild branch
2+
# and sets an output variable IsRebuildBranch that can be used by other templates
3+
steps:
4+
- pwsh: |
5+
# Check if this is a rebuild branch (e.g., rebuild/v7.4.13-rebuild.5)
6+
$isRebuildBranch = '$(Build.SourceBranch)' -match 'refs/heads/rebuild/.*-rebuild\.'
7+
8+
$value = if ($isRebuildBranch) { 'true' } else { 'false' }
9+
Write-Verbose -Message "IsRebuildBranch: $value" -Verbose
10+
11+
if ($isRebuildBranch) {
12+
Write-Verbose -Message "Rebuild branch detected: $(Build.SourceBranch)" -Verbose
13+
}
14+
15+
Write-Host "##vso[task.setvariable variable=IsRebuildBranch;isOutput=true]$value"
16+
name: RebuildBranchCheck
17+
displayName: Check if Rebuild Branch

0 commit comments

Comments
 (0)