-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support creating release branches when releasing new versions #1627
Merged
alcaeus
merged 3 commits into
mongodb:v1.x
from
alcaeus:support-branching-from-releases
Mar 12, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,9 @@ jobs: | |
- name: "Store version numbers in env variables" | ||
run: | | ||
echo RELEASE_VERSION=${{ inputs.version }} >> $GITHUB_ENV | ||
echo RELEASE_VERSION_WITHOUT_STABILITY=$(echo ${{ inputs.version }} | awk -F- '{print $1}') >> $GITHUB_ENV | ||
echo RELEASE_BRANCH=v$(echo ${{ inputs.version }} | cut -d '.' -f-2) >> $GITHUB_ENV | ||
echo DEV_BRANCH=v$(echo ${{ inputs.version }} | cut -d '.' -f-1).x >> $GITHUB_ENV | ||
|
||
- name: "Ensure release tag does not already exist" | ||
run: | | ||
|
@@ -66,12 +68,31 @@ jobs: | |
exit 1 | ||
fi | ||
|
||
- name: "Fail if branch names don't match" | ||
if: ${{ github.ref_name != env.RELEASE_BRANCH }} | ||
# For patch releases (A.B.C where C != 0), we expect the release to be | ||
# triggered from the A.B maintenance branch | ||
- name: "Fail if patch release is created from wrong release branch" | ||
if: ${{ !endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.RELEASE_BRANCH != github.ref_name }} | ||
run: | | ||
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
|
||
# For non-patch releases (A.B.C where C == 0), we expect the release to | ||
# be triggered from the A.B maintenance branch or A.x development branch | ||
- name: "Fail if non-patch release is created from wrong release branch" | ||
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.RELEASE_BRANCH != github.ref_name && env.DEV_BRANCH != github.ref_name }} | ||
run: | | ||
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 | ||
exit 1 | ||
|
||
# If a non-patch release is created from its A.x development branch, | ||
# create the A.B maintenance branch from the current one and push it | ||
- name: "Create and push new release branch for non-patch release" | ||
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.DEV_BRANCH == github.ref_name }} | ||
run: | | ||
echo '🆕 Creating new release branch ${RELEASE_BRANCH} from ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY | ||
git checkout -b ${RELEASE_BRANCH} | ||
git push origin ${RELEASE_BRANCH} | ||
|
||
# | ||
# Preliminary checks done - commence the release process | ||
# | ||
|
@@ -90,7 +111,7 @@ jobs: | |
EOL | ||
|
||
- name: "Create draft release" | ||
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ github.ref_name }} --title "${{ inputs.version }}" --notes-file release-message --draft)" >> "$GITHUB_ENV" | ||
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ env.RELEASE_BRANCH }} --title "${{ inputs.version }}" --notes-file release-message --draft)" >> "$GITHUB_ENV" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the (potentially newly created) release branch ensures that GitHub shows the correct "x commits to " when looking at a release on GitHub. |
||
|
||
- name: "Create release tag" | ||
uses: mongodb-labs/drivers-github-tools/tag-version@v2 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary as we need to check for a patch release. The best way is to cut the suffix (e.g.
-RC0
) from the version and only keep the major, minor, and patch numbers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted that this is using the
-F sepstring
syntax from awk(1p). It wasn't immediately clear to me due to the omitted space, but https://askubuntu.com/a/342850 helped clarify.