Skip to content

Commit 280247c

Browse files
Merge v1.x into v2.x (#1635)
2 parents 2e9b74f + be5f634 commit 280247c

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

.github/workflows/release.yml

+24-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ jobs:
5757
- name: "Store version numbers in env variables"
5858
run: |
5959
echo RELEASE_VERSION=${{ inputs.version }} >> $GITHUB_ENV
60+
echo RELEASE_VERSION_WITHOUT_STABILITY=$(echo ${{ inputs.version }} | awk -F- '{print $1}') >> $GITHUB_ENV
6061
echo RELEASE_BRANCH=v$(echo ${{ inputs.version }} | cut -d '.' -f-2) >> $GITHUB_ENV
62+
echo DEV_BRANCH=v$(echo ${{ inputs.version }} | cut -d '.' -f-1).x >> $GITHUB_ENV
6163
6264
- name: "Ensure release tag does not already exist"
6365
run: |
@@ -66,12 +68,31 @@ jobs:
6668
exit 1
6769
fi
6870
69-
- name: "Fail if branch names don't match"
70-
if: ${{ github.ref_name != env.RELEASE_BRANCH }}
71+
# For patch releases (A.B.C where C != 0), we expect the release to be
72+
# triggered from the A.B maintenance branch
73+
- name: "Fail if patch release is created from wrong release branch"
74+
if: ${{ !endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.RELEASE_BRANCH != github.ref_name }}
7175
run: |
7276
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
7377
exit 1
7478
79+
# For non-patch releases (A.B.C where C == 0), we expect the release to
80+
# be triggered from the A.B maintenance branch or A.x development branch
81+
- name: "Fail if non-patch release is created from wrong release branch"
82+
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.RELEASE_BRANCH != github.ref_name && env.DEV_BRANCH != github.ref_name }}
83+
run: |
84+
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }} or ${{ env.DEV_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
85+
exit 1
86+
87+
# If a non-patch release is created from its A.x development branch,
88+
# create the A.B maintenance branch from the current one and push it
89+
- name: "Create and push new release branch for non-patch release"
90+
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.DEV_BRANCH == github.ref_name }}
91+
run: |
92+
echo '🆕 Creating new release branch ${RELEASE_BRANCH} from ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
93+
git checkout -b ${RELEASE_BRANCH}
94+
git push origin ${RELEASE_BRANCH}
95+
7596
#
7697
# Preliminary checks done - commence the release process
7798
#
@@ -90,7 +111,7 @@ jobs:
90111
EOL
91112
92113
- name: "Create draft release"
93-
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ github.ref_name }} --title "${{ inputs.version }}" --notes-file release-message --draft)" >> "$GITHUB_ENV"
114+
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ env.RELEASE_BRANCH }} --title "${{ inputs.version }}" --notes-file release-message --draft)" >> "$GITHUB_ENV"
94115

95116
- name: "Create release tag"
96117
uses: mongodb-labs/drivers-github-tools/tag-version@v2

0 commit comments

Comments
 (0)