Skip to content

Release 5.1.2

Release 5.1.2 #2

Workflow file for this run

name: "Release New Version"
run-name: "Release ${{ inputs.version }}"
on:
workflow_dispatch:
inputs:
version:
description: "The version to be released (e.g. 1.2.3)"
required: true
type: "string"
env:
GIT_AUTHOR_EMAIL: "167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com"
GIT_AUTHOR_NAME: "mongodb-dbx-release-bot[bot]"
jobs:
prepare-release:
environment: release
name: "Prepare release"
runs-on: ubuntu-latest
permissions:
# Write permission for id-token is necessary to generate a new token for the GitHub App
id-token: write
# Write permission for contents is to ensure we're allowed to push to the repository
contents: write
steps:
- name: "Create release output"
run: echo '🎬 Release process for version ${{ env.RELEASE_VERSION }} started by @${{ github.triggering_actor }}' >> $GITHUB_STEP_SUMMARY
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
with:
app_id: ${{ vars.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: "Store version numbers in env variables"
# The awk command to increase the version number was copied from
# StackOverflow: https://stackoverflow.com/a/61921674/3959933
run: |
echo RELEASE_VERSION=${{ inputs.version }} >> $GITHUB_ENV
echo NEXT_VERSION=$(echo ${{ inputs.version }} | awk -F. -v OFS=. '{$NF += 1 ; print}') >> $GITHUB_ENV
echo RELEASE_BRANCH=$(echo ${{ inputs.version }} | awk -F. -v OFS=. '{$NF = "x" ; print}') >> $GITHUB_ENV
- name: "Ensure release tag does not already exist"
run: |
if [[ $(git tag -l r${RELEASE_VERSION}) == r${RELEASE_VERSION} ]]; then
echo '❌ Release failed: tag for version ${{ inputs.version }} already exists' >> $GITHUB_STEP_SUMMARY
exit 1
fi
# For patch releases (A.B.C where C != 0), we expect the release to be
# triggered from the A.B.x maintenance branch
- name: "Fail if patch release is created from wrong release branch"
if: ${{ !endsWith(inputs.version, '.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 master or the A.B.x maintenance branch
- name: "Fail if non-patch release is created from wrong release branch"
if: ${{ endsWith(inputs.version, '.0') && env.RELEASE_BRANCH != github.ref_name && github.ref_name != 'master' }}
run: |
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }} or master, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
exit 1
# If a non-patch release is created from a branch other than its
# maintenance branch, create that branch from the current one and push it
- name: "Create new release branch for non-patch release"
if: ${{ endsWith(inputs.version, '.0') && env.RELEASE_BRANCH != github.ref_name }}
run: |
echo '🆕 Creating new release branch ${RELEASE_BRANCH} from ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
git checkout -b ${RELEASE_BRANCH}
- name: "Set git author information"
run: |
git config user.name "${GIT_AUTHOR_NAME}"
git config user.email "${GIT_AUTHOR_EMAIL}"
# This step bumps version numbers in build.gradle and creates git artifacts for the release
- name: "Bump version numbers and create release tag"
run: .github/workflows/bump-and-tag.sh
- name: "Push release branch and tag"
run: |
git push origin ${RELEASE_BRANCH}
git push origin r${{ env.RELEASE_VERSION }}
- name: "Create draft release with generated changelog"
run: |
echo "RELEASE_URL=$(\
gh release create r${RELEASE_VERSION} \
--target ${{ env.RELEASE_BRANCH }} \
--title "Java Driver ${{ env.RELEASE_VERSION }} ($(date '+%B %d, %Y'))" \
--generate-notes \
--draft\
)" >> "$GITHUB_ENV"
- name: "Set summary"
run: |
echo '🚀 Created tag and drafted release for version [${{ env.RELEASE_VERSION }}](${{ env.RELEASE_URL }})' >> $GITHUB_STEP_SUMMARY
echo '✍️ You may now update the release notes and publish the release when ready' >> $GITHUB_STEP_SUMMARY