Skip to content

Commit 4fd5013

Browse files
authored
Merge pull request #713 from CommunityToolkit/ci/weekly-releases-tagging
Add tag‑based weekly scheduled incremental CI builds
2 parents 00d77f2 + ccf23a0 commit 4fd5013

File tree

2 files changed

+61
-13
lines changed

2 files changed

+61
-13
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ on:
1818

1919
# Allow this workflow to be called as a reusable workflow
2020
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
2130

2231
env:
2332
DOTNET_VERSION: ${{ '9.0.x' }}
@@ -46,6 +55,9 @@ jobs:
4655
uses: actions/checkout@v4
4756
with:
4857
submodules: recursive
58+
ref: ${{ inputs.commit_range_end || github.sha }}
59+
fetch-depth: 0
60+
fetch-tags: true
4961

5062
# Restore Tools from Manifest list in the Repository
5163
- name: Restore dotnet tools
@@ -84,11 +96,13 @@ jobs:
8496
uses: actions/checkout@v4
8597
with:
8698
submodules: recursive
99+
ref: ${{ inputs.commit_range_end || github.sha }}
87100
fetch-depth: 0
101+
fetch-tags: true
88102

89103
- name: Get changed components
90104
run: |
91-
$changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ github.event.before }} ${{ github.event.after }})
105+
$changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ inputs.commit_range_start || github.event.before }} ${{ inputs.commit_range_end || github.event.after }})
92106
$buildableChangedComponents = $(./tooling/MultiTarget/Filter-Supported-Components.ps1 -Components $changedComponents -MultiTargets ${{ matrix.multitarget }} -WinUIMajorVersion ${{ matrix.winui }})
93107
echo "CHANGED_COMPONENTS_LIST=$(($buildableChangedComponents | ForEach-Object { "$_" }) -join ',')" >> $env:GITHUB_ENV
94108
echo "HAS_BUILDABLE_COMPONENTS=$($buildableChangedComponents.Count -gt 0)" >> $env:GITHUB_ENV
@@ -248,7 +262,9 @@ jobs:
248262
uses: actions/checkout@v4
249263
with:
250264
submodules: recursive
265+
ref: ${{ inputs.commit_range_end || github.sha }}
251266
fetch-depth: 0
267+
fetch-tags: true
252268

253269
- name: Format Date/Time of Commit for Package Version
254270
run: |
@@ -275,7 +291,7 @@ jobs:
275291
# Get changed components
276292
- name: Get changed components
277293
run: |
278-
$changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ github.event.before }} ${{ github.event.after }})
294+
$changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ inputs.commit_range_start || github.event.before }} ${{ inputs.commit_range_end || github.event.after }})
279295
$buildableChangedComponents = $(./tooling/MultiTarget/Filter-Supported-Components.ps1 -Components $changedComponents -MultiTargets "all" -WinUIMajorVersion ${{ matrix.winui }})
280296
echo "CHANGED_COMPONENTS_LIST=$(($buildableChangedComponents | ForEach-Object { "$_" }) -join ',')" >> $env:GITHUB_ENV
281297
echo "HAS_BUILDABLE_COMPONENTS=$($buildableChangedComponents.Count -gt 0)" >> $env:GITHUB_ENV
@@ -440,6 +456,9 @@ jobs:
440456
uses: actions/checkout@v4
441457
with:
442458
submodules: recursive
459+
ref: ${{ inputs.commit_range_end || github.sha }}
460+
fetch-depth: 0
461+
fetch-tags: true
443462

444463
# Restore Tools from Manifest list in the Repository
445464
- name: Restore dotnet tools

.github/workflows/scheduled-releases.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
merge-weekly:
12+
tag-weekly-release:
1313
runs-on: ubuntu-latest
1414
permissions:
1515
contents: write
16+
outputs:
17+
commit_range_start: ${{ steps.range.outputs.commit_range_start }}
18+
commit_range_end: ${{ steps.range.outputs.commit_range_end }}
1619

1720
steps:
1821
- name: Checkout repository
@@ -26,17 +29,43 @@ jobs:
2629
run: |
2730
git config user.name 'github-actions[bot]'
2831
git config user.email 'github-actions[bot]@users.noreply.github.com'
32+
33+
- name: Create tag
34+
id: create-tag
35+
run: |
36+
# Date in the format YYMMDD
37+
TAG="release/weekly/$(date +%y%m%d)"
38+
git tag -a "$TAG" -m "Release $TAG"
39+
git push origin "$TAG"
40+
echo "TAG=$TAG" >> $GITHUB_OUTPUT
2941
30-
- name: Merge main into rel/weekly
42+
- name: Determine commit range
43+
id: range
3144
run: |
32-
git fetch origin
33-
git checkout rel/weekly
34-
git reset --hard origin/rel/weekly
35-
git merge --ff-only origin/main -m "Weekly merge of main into rel/weekly"
36-
git push origin rel/weekly
45+
# New tag we just created
46+
NEW_TAG=${{ steps.create-tag.outputs.TAG }}
47+
48+
# Find the previous tag (sorted newest‑first)
49+
PREV_TAG=$(git tag --list "release/weekly/*" --sort=-creatordate | sed -n '2p')
50+
51+
# If we’re on the very first tag, fall back to main
52+
if [ -z "$PREV_TAG" ]; then
53+
PREV_TAG=main
54+
fi
55+
56+
# Resolve the commit hashes
57+
START_COMMIT=$(git rev-parse "$PREV_TAG")
58+
END_COMMIT=$(git rev-parse "$NEW_TAG")
59+
60+
# Export them as workflow outputs
61+
echo "commit_range_start=$START_COMMIT" >> $GITHUB_OUTPUT
62+
echo "commit_range_end=$END_COMMIT" >> $GITHUB_OUTPUT
3763
38-
# Then trigger the build workflow on the updated rel/weekly branch
64+
# Then trigger the build workflow with the commit range.
3965
trigger-build:
40-
needs: merge-weekly
41-
uses: CommunityToolkit/Labs-Windows/.github/workflows/build.yml@rel/weekly
42-
secrets: inherit
66+
needs: tag-weekly-release
67+
uses: ./.github/workflows/build.yml
68+
with:
69+
commit_range_start: ${{ needs.tag-weekly-release.outputs.commit_range_start }}
70+
commit_range_end: ${{ needs.tag-weekly-release.outputs.commit_range_end }}
71+
secrets: inherit

0 commit comments

Comments
 (0)