99 # Triggers the workflow on push or pull request events but only for the main branch
1010 push :
1111 branches : [ main ]
12+ tags : [ 'release/weekly/*' ]
1213 pull_request :
1314 branches : [ main ]
1415
1516 # Allows you to run this workflow manually from the Actions tab
1617 workflow_dispatch :
1718 merge_group :
18-
19- # Allow this workflow to be called as a reusable workflow
20- workflow_call :
21- inputs :
22- commit_range_start :
23- description : ' The start commit of the range to check for incremental builds.'
24- type : string
25- required : false
26- commit_range_end :
27- description : ' The end commit of the range to check for incremental builds.'
28- type : string
29- required : false
30- is_scheduled :
31- description : ' A boolean value that indicates whether this is a scheduled run.'
32- type : boolean
33- required : false
3419
3520env :
3621 DOTNET_VERSION : ${{ '9.0.x' }}
5944 uses : actions/checkout@v4
6045 with :
6146 submodules : recursive
62- ref : ${{ inputs.commit_range_end || github.sha }}
47+ ref : ${{ github.sha }}
6348 fetch-depth : 0
6449 fetch-tags : true
6550
@@ -100,13 +85,23 @@ jobs:
10085 uses : actions/checkout@v4
10186 with :
10287 submodules : recursive
103- ref : ${{ inputs.commit_range_end || github.sha }}
88+ ref : ${{ github.sha }}
10489 fetch-depth : 0
10590 fetch-tags : true
91+
92+ - name : Determine scheduled release commit range
93+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
94+ id : range
95+ shell : pwsh
96+ run : |
97+ # Previous weekly tag (2nd newest); fallback to main's HEAD
98+ $prevTag = git tag --list 'release/weekly/*' --sort=-creatordate | Select-Object -Skip 1 -First 1
99+ $tagSha = [string]::IsNullOrWhiteSpace($prevTag) ? (git rev-parse 'origin/main').Trim() : (git rev-list -n 1 $prevTag).Trim()
100+ "PREV_TAG_COMMIT=$tagSha" >> $env:GITHUB_ENV
106101
107102 - name : Get changed components
108103 run : |
109- $changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ inputs.commit_range_start || github.event.before }} ${{ inputs.commit_range_end || github.event.after }})
104+ $changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ env.PREV_TAG_COMMIT || github.event.before }} ${{ github.sha || github.event.after }})
110105 $buildableChangedComponents = $(./tooling/MultiTarget/Filter-Supported-Components.ps1 -Components $changedComponents -MultiTargets ${{ matrix.multitarget }} -WinUIMajorVersion ${{ matrix.winui }})
111106 echo "CHANGED_COMPONENTS_LIST=$(($buildableChangedComponents | ForEach-Object { "$_" }) -join ',')" >> $env:GITHUB_ENV
112107 echo "HAS_BUILDABLE_COMPONENTS=$($buildableChangedComponents.Count -gt 0)" >> $env:GITHUB_ENV
@@ -266,7 +261,7 @@ jobs:
266261 uses : actions/checkout@v4
267262 with :
268263 submodules : recursive
269- ref : ${{ inputs.commit_range_end || github.sha }}
264+ ref : ${{ github.sha }}
270265 fetch-depth : 0
271266 fetch-tags : true
272267
@@ -292,10 +287,20 @@ jobs:
292287 uses : microsoft/setup-msbuild@v2
293288 with :
294289 vs-version : ' [17.9,)'
295- # Get changed components
290+
291+ - name : Determine scheduled release commit range
292+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
293+ id : range
294+ shell : pwsh
295+ run : |
296+ # Previous weekly tag (2nd newest); fallback to main's HEAD
297+ $prevTag = git tag --list 'release/weekly/*' --sort=-creatordate | Select-Object -Skip 1 -First 1
298+ $tagSha = [string]::IsNullOrWhiteSpace($prevTag) ? (git rev-parse 'origin/main').Trim() : (git rev-list -n 1 $prevTag).Trim()
299+ "PREV_TAG_COMMIT=$tagSha" >> $env:GITHUB_ENV
300+
296301 - name : Get changed components
297302 run : |
298- $changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ inputs.commit_range_start || github.event.before }} ${{ inputs.commit_range_end || github.event.after }})
303+ $changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ env.PREV_TAG_COMMIT || github.event.before }} ${{ github.event.after || github.sha }})
299304 $buildableChangedComponents = $(./tooling/MultiTarget/Filter-Supported-Components.ps1 -Components $changedComponents -MultiTargets "all" -WinUIMajorVersion ${{ matrix.winui }})
300305 echo "CHANGED_COMPONENTS_LIST=$(($buildableChangedComponents | ForEach-Object { "$_" }) -join ',')" >> $env:GITHUB_ENV
301306 echo "HAS_BUILDABLE_COMPONENTS=$($buildableChangedComponents.Count -gt 0)" >> $env:GITHUB_ENV
@@ -354,7 +359,7 @@ jobs:
354359
355360 sign :
356361 needs : [package]
357- if : ${{ startsWith(github.ref, 'refs/heads/rel/') || inputs.is_scheduled }}
362+ if : ${{ startsWith(github.ref, 'refs/heads/rel/') || startsWith(github.ref, 'refs/tags/') }}
358363 runs-on : windows-latest
359364 permissions :
360365 id-token : write # Required for requesting the JWT
@@ -411,15 +416,15 @@ jobs:
411416
412417 - name : Upload Signed Packages as Artifacts (for release)
413418 uses : actions/upload-artifact@v4
414- if : ${{ startsWith(github.ref, 'refs/heads/rel/') || inputs.is_scheduled }}
419+ if : ${{ startsWith(github.ref, 'refs/heads/rel/') || startsWith(github.ref, 'refs/tags/') }}
415420 with :
416421 name : signed-nuget-packages-${{ matrix.winui }}
417422 if-no-files-found : error
418423 path : |
419424 ${{ github.workspace }}/packages/**/*.nupkg
420425
421426 release :
422- if : ${{ startsWith(github.ref, 'refs/heads/rel/') || inputs.is_scheduled }}
427+ if : ${{ startsWith(github.ref, 'refs/heads/rel/') || startsWith(github.ref, 'refs/tags/') }}
423428 needs : [sign]
424429 environment : nuget-release-gate # This gates this job until manually approved
425430 runs-on : ubuntu-latest
@@ -469,7 +474,7 @@ jobs:
469474 uses : actions/checkout@v4
470475 with :
471476 submodules : recursive
472- ref : ${{ inputs.commit_range_end || github.sha }}
477+ ref : ${{ github.sha }}
473478 fetch-depth : 0
474479 fetch-tags : true
475480
0 commit comments