Skip to content

Commit 90f9a30

Browse files
committed
Use same logic as in laravel integration
1 parent 63239c7 commit 90f9a30

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

.github/workflows/release.yml

+14-14
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
echo RELEASE_VERSION=${{ inputs.version }} >> $GITHUB_ENV
6060
echo RELEASE_VERSION_WITHOUT_STABILITY=$(echo ${{ inputs.version }} | awk -F- '{print $1}') >> $GITHUB_ENV
6161
echo RELEASE_BRANCH=v$(echo ${{ inputs.version }} | cut -d '.' -f-2) >> $GITHUB_ENV
62-
echo DEVELOPMENT_BRANCH=v$(echo ${{ inputs.version }} | cut -d '.' -f-1).x >> $GITHUB_ENV
62+
echo DEV_BRANCH=v$(echo ${{ inputs.version }} | cut -d '.' -f-1).x >> $GITHUB_ENV
6363
6464
- name: "Ensure release tag does not already exist"
6565
run: |
@@ -69,34 +69,34 @@ jobs:
6969
fi
7070
7171
# For patch releases (A.B.C where C != 0), we expect the release to be
72-
# triggered from the vA.B release branch
72+
# triggered from the A.B maintenance branch
7373
- name: "Fail if patch release is created from wrong release branch"
7474
if: ${{ !endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.RELEASE_BRANCH != github.ref_name }}
7575
run: |
7676
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
7777
exit 1
7878
7979
# For non-patch releases (A.B.C where C == 0), we expect the release to
80-
# be triggered from the vA.x development branch or the vA.B release branch.
81-
# This includes pre-releases (e.g. alpha, beta, rc)
80+
# be triggered from the A.x maintenance branch or A.x development branch
8281
- name: "Fail if non-patch release is created from wrong release branch"
83-
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.RELEASE_BRANCH != github.ref_name && env.DEVELOPMENT_BRANCH != github.ref_name }}
82+
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.RELEASE_BRANCH != github.ref_name && env.DEV_BRANCH != github.ref_name }}
8483
run: |
85-
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }} or ${{ env.DEVELOPMENT_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
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
8685
exit 1
8786
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+
8896
#
8997
# Preliminary checks done - commence the release process
9098
#
9199

92-
# Create the new release branch if we're releasing from the vA.x
93-
# development branch
94-
- name: "Create new release branch"
95-
if: ${{ github.ref_name != env.RELEASE_BRANCH }}
96-
run: |
97-
git checkout -b ${{ env.RELEASE_BRANCH }}
98-
git push origin ${{ env.RELEASE_BRANCH }}
99-
100100
- name: "Set up drivers-github-tools"
101101
uses: mongodb-labs/drivers-github-tools/setup@v2
102102
with:

0 commit comments

Comments
 (0)