@@ -43,20 +43,52 @@ jobs:
4343 - name : Checkout repository
4444 uses : actions/checkout@v5
4545 with :
46- # We usually expect to checkout `inputs.rollback-tag` (required for `workflow_dispatch`),
47- # but use `needs.prepare.outputs.latest_tag` for testing.
48- ref : ${{ inputs.rollback-tag || needs.prepare.outputs.latest_tag }}
4946 fetch-depth : 0 # Need full history for calculation of diffs
5047
5148 - name : Configure runner for release
5249 uses : ./.github/actions/release-initialise
5350
51+ # We start by preparing the mergeback branch, mainly so that we have the updated changelog
52+ # readily available for the partial changelog that's needed for the release.
53+ - name : Prepare mergeback branch
54+ id : mergeback-branch
55+ env :
56+ BASE_BRANCH : " main"
57+ VERSION : ${{ needs.prepare.outputs.version }}
58+ run : |
59+ set -x
60+
61+ # Generate a new branch name for the mergeback PR
62+ short_sha="${GITHUB_SHA:0:8}"
63+ NEW_BRANCH="mergeback/${VERSION}-to-${BASE_BRANCH}-${short_sha}"
64+ echo "new-branch=${NEW_BRANCH}" >> $GITHUB_OUTPUT
65+
66+ # Create the mergeback branch
67+ git checkout -b "${NEW_BRANCH}"
68+
69+ - name : Prepare rollback changelog
70+ env :
71+ NEW_CHANGELOG : " ${{ runner.temp }}/new_changelog.md"
72+ ROLLBACK_TAG : ${{ inputs.rollback-tag || needs.prepare.outputs.latest_tag }}
73+ LATEST_TAG : ${{ needs.prepare.outputs.latest_tag }}
74+ VERSION : " ${{ needs.prepare.outputs.version }}"
75+ run : |
76+ python .github/workflows/script/rollback_changelog.py "${ROLLBACK_TAG:1}" "${LATEST_TAG:1}" "$VERSION" > $NEW_CHANGELOG
77+
78+ echo "::group::New CHANGELOG"
79+ cat $NEW_CHANGELOG
80+ echo "::endgroup::"
81+
5482 - name : Create tags
5583 shell : bash
5684 env :
85+ # We usually expect to checkout `inputs.rollback-tag` (required for `workflow_dispatch`),
86+ # but use `needs.prepare.outputs.latest_tag` for testing.
87+ ROLLBACK_TAG : ${{ inputs.rollback-tag || needs.prepare.outputs.latest_tag }}
5788 RELEASE_TAG : ${{ needs.prepare.outputs.version }}
5889 MAJOR_VERSION_TAG : ${{ needs.prepare.outputs.major_version }}
5990 run : |
91+ git checkout "refs/tags/${ROLLBACK_TAG}"
6092 git tag --annotate "${RELEASE_TAG}" --message "${RELEASE_TAG}"
6193 git tag --annotate "${MAJOR_VERSION_TAG}" --message "${MAJOR_VERSION_TAG}" --force
6294
@@ -71,10 +103,11 @@ jobs:
71103
72104 - name : Prepare partial Changelog
73105 env :
106+ NEW_CHANGELOG : " ${{ runner.temp }}/new_changelog.md"
74107 PARTIAL_CHANGELOG : " ${{ runner.temp }}/partial_changelog.md"
75108 VERSION : " ${{ needs.prepare.outputs.version }}"
76109 run : |
77- python .github/workflows/script/prepare_changelog.py CHANGELOG.md "$VERSION" > $PARTIAL_CHANGELOG
110+ python .github/workflows/script/prepare_changelog.py $NEW_CHANGELOG "$VERSION" > $PARTIAL_CHANGELOG
78111
79112 echo "::group::Partial CHANGELOG"
80113 cat $PARTIAL_CHANGELOG
88121 app-id : ${{ vars.AUTOMATION_APP_ID }}
89122 private-key : ${{ secrets.AUTOMATION_PRIVATE_KEY }}
90123
91- - name : Create the GitHub release
124+ - name : Create the rollback release
92125 if : github.event_name == 'workflow_dispatch'
93126 env :
94127 PARTIAL_CHANGELOG : " ${{ runner.temp }}/partial_changelog.md"
@@ -103,3 +136,16 @@ jobs:
103136 --draft \
104137 --title "$VERSION" \
105138 --notes-file "$PARTIAL_CHANGELOG"
139+
140+ - name : Create mergeback branch and PR
141+ uses : ./.github/actions/prepare-mergeback-branch
142+ with :
143+ base : " main"
144+ head : " "
145+ branch : " ${{ steps.mergeback-branch.outputs.new-branch }}"
146+ version : " ${{ needs.prepare.outputs.version }}"
147+ token : " ${{ secrets.GITHUB_TOKEN }}"
148+ # Setting this to `true` for non-workflow_dispatch events will
149+ # still push the `branch`, but won't create a corresponding PR
150+ dry-run : " ${{ github.event_name != 'workflow_dispatch' }}"
151+
0 commit comments