diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd661f819..297f69b52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,15 @@ on: # Allow this workflow to be called as a reusable workflow workflow_call: + inputs: + commit_range_start: + description: 'The start commit of the range to check for incremental builds.' + type: string + required: false + commit_range_end: + description: 'The end commit of the range to check for incremental builds.' + type: string + required: false env: DOTNET_VERSION: ${{ '9.0.x' }} @@ -46,6 +55,9 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + ref: ${{ inputs.commit_range_end || github.sha }} + fetch-depth: 0 + fetch-tags: true # Restore Tools from Manifest list in the Repository - name: Restore dotnet tools @@ -84,11 +96,13 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + ref: ${{ inputs.commit_range_end || github.sha }} fetch-depth: 0 + fetch-tags: true - name: Get changed components run: | - $changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ github.event.before }} ${{ github.event.after }}) + $changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ inputs.commit_range_start || github.event.before }} ${{ inputs.commit_range_end || github.event.after }}) $buildableChangedComponents = $(./tooling/MultiTarget/Filter-Supported-Components.ps1 -Components $changedComponents -MultiTargets ${{ matrix.multitarget }} -WinUIMajorVersion ${{ matrix.winui }}) echo "CHANGED_COMPONENTS_LIST=$(($buildableChangedComponents | ForEach-Object { "$_" }) -join ',')" >> $env:GITHUB_ENV echo "HAS_BUILDABLE_COMPONENTS=$($buildableChangedComponents.Count -gt 0)" >> $env:GITHUB_ENV @@ -248,7 +262,9 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + ref: ${{ inputs.commit_range_end || github.sha }} fetch-depth: 0 + fetch-tags: true - name: Format Date/Time of Commit for Package Version run: | @@ -275,7 +291,7 @@ jobs: # Get changed components - name: Get changed components run: | - $changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ github.event.before }} ${{ github.event.after }}) + $changedComponents = $(./tooling/Get-Changed-Components.ps1 ${{ inputs.commit_range_start || github.event.before }} ${{ inputs.commit_range_end || github.event.after }}) $buildableChangedComponents = $(./tooling/MultiTarget/Filter-Supported-Components.ps1 -Components $changedComponents -MultiTargets "all" -WinUIMajorVersion ${{ matrix.winui }}) echo "CHANGED_COMPONENTS_LIST=$(($buildableChangedComponents | ForEach-Object { "$_" }) -join ',')" >> $env:GITHUB_ENV echo "HAS_BUILDABLE_COMPONENTS=$($buildableChangedComponents.Count -gt 0)" >> $env:GITHUB_ENV @@ -440,6 +456,9 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + ref: ${{ inputs.commit_range_end || github.sha }} + fetch-depth: 0 + fetch-tags: true # Restore Tools from Manifest list in the Repository - name: Restore dotnet tools diff --git a/.github/workflows/scheduled-releases.yml b/.github/workflows/scheduled-releases.yml index cce92f5fe..0b4b8b193 100644 --- a/.github/workflows/scheduled-releases.yml +++ b/.github/workflows/scheduled-releases.yml @@ -9,10 +9,13 @@ on: workflow_dispatch: jobs: - merge-weekly: + tag-weekly-release: runs-on: ubuntu-latest permissions: contents: write + outputs: + commit_range_start: ${{ steps.range.outputs.commit_range_start }} + commit_range_end: ${{ steps.range.outputs.commit_range_end }} steps: - name: Checkout repository @@ -26,17 +29,43 @@ jobs: run: | git config user.name 'github-actions[bot]' git config user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Create tag + id: create-tag + run: | + # Date in the format YYMMDD + TAG="release/weekly/$(date +%y%m%d)" + git tag -a "$TAG" -m "Release $TAG" + git push origin "$TAG" + echo "TAG=$TAG" >> $GITHUB_OUTPUT - - name: Merge main into rel/weekly + - name: Determine commit range + id: range run: | - git fetch origin - git checkout rel/weekly - git reset --hard origin/rel/weekly - git merge --ff-only origin/main -m "Weekly merge of main into rel/weekly" - git push origin rel/weekly + # New tag we just created + NEW_TAG=${{ steps.create-tag.outputs.TAG }} + + # Find the previous tag (sorted newest‑first) + PREV_TAG=$(git tag --list "release/weekly/*" --sort=-creatordate | sed -n '2p') + + # If we’re on the very first tag, fall back to main + if [ -z "$PREV_TAG" ]; then + PREV_TAG=main + fi + + # Resolve the commit hashes + START_COMMIT=$(git rev-parse "$PREV_TAG") + END_COMMIT=$(git rev-parse "$NEW_TAG") + + # Export them as workflow outputs + echo "commit_range_start=$START_COMMIT" >> $GITHUB_OUTPUT + echo "commit_range_end=$END_COMMIT" >> $GITHUB_OUTPUT - # Then trigger the build workflow on the updated rel/weekly branch + # Then trigger the build workflow with the commit range. trigger-build: - needs: merge-weekly - uses: CommunityToolkit/Labs-Windows/.github/workflows/build.yml@rel/weekly - secrets: inherit + needs: tag-weekly-release + uses: ./.github/workflows/build.yml + with: + commit_range_start: ${{ needs.tag-weekly-release.outputs.commit_range_start }} + commit_range_end: ${{ needs.tag-weekly-release.outputs.commit_range_end }} + secrets: inherit \ No newline at end of file