From bd1ea31d2fae00879fda3c9f98a40dbc79508d45 Mon Sep 17 00:00:00 2001 From: Iris Date: Tue, 24 Nov 2026 09:40:05 -0800 Subject: [PATCH 1/4] PYTHON-5941 automatically create release branch for minor releases --- .github/workflows/create-release-branch.yml | 56 +++++++++++++++++++-- .github/workflows/release-python.yml | 14 ++++++ 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml index abcf095c04..e2b338a0db 100644 --- a/.github/workflows/create-release-branch.yml +++ b/.github/workflows/create-release-branch.yml @@ -14,6 +14,23 @@ on: push_changes: description: Whether to push the changes default: "true" + workflow_call: + inputs: + version: + description: >- + The released version. A branch is only created for a new + major/minor line (X.Y.0); patch releases reuse the existing branch. + required: true + type: string + base_ref: + description: The base reference for the branch (typically the release tag) + required: false + type: string + push_changes: + description: Whether to push the changes + required: false + type: string + default: "true" concurrency: group: create-branch-${{ github.ref }} @@ -24,14 +41,44 @@ defaults: shell: bash -eux {0} jobs: + release-branch: + runs-on: ubuntu-latest + outputs: + create: ${{ steps.compute.outputs.create }} + branch_name: ${{ steps.compute.outputs.branch_name }} + steps: + - name: Compute the release branch name + id: compute + shell: bash -eu {0} + env: + VERSION: ${{ inputs.version }} + BRANCH_NAME: ${{ inputs.branch_name }} + run: | + # A release branch is only created for a new major/minor line (X.Y.0); + # an explicitly provided branch_name (manual dispatch) always wins. + # Dry runs pass a ref rather than a version, so they never create branches. + if [ -n "$BRANCH_NAME" ]; then + branch_name="$BRANCH_NAME" + elif [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.0$ ]]; then + branch_name="v$(echo "$VERSION" | cut -d. -f1-2)" + else + branch_name="" + fi + if [ -n "$branch_name" ]; then + echo "create=true" >> "$GITHUB_OUTPUT" + else + echo "create=false" >> "$GITHUB_OUTPUT" + fi + echo "branch_name=$branch_name" >> "$GITHUB_OUTPUT" + create-branch: + needs: release-branch + if: needs.release-branch.outputs.create == 'true' environment: release runs-on: ubuntu-latest permissions: id-token: write contents: write - outputs: - version: ${{ steps.pre-publish.outputs.version }} steps: - name: Create app token id: app-token @@ -50,7 +97,8 @@ jobs: with: ref: ${{ github.ref }} token: ${{ env.GH_TOKEN }} - fetch-depth: 1 + # Full history and tags so base_ref (the release tag) can be resolved. + fetch-depth: 0 persist-credentials: false - name: Configure git auth for push shell: bash -eu {0} @@ -68,7 +116,7 @@ jobs: - uses: mongodb-labs/drivers-github-tools/create-branch@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 id: create-branch with: - branch_name: ${{ inputs.branch_name }} + branch_name: ${{ needs.release-branch.outputs.branch_name }} version: ${{ inputs.version }} base_ref: ${{ inputs.base_ref }} push_changes: ${{ inputs.push_changes }} diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 74e682bba9..572a4fa6cb 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -109,3 +109,17 @@ jobs: evergreen_project: ${{ env.EVERGREEN_PROJECT }} token: ${{ github.token }} dry_run: ${{ env.DRY_RUN }} + + create-release-branch: + # Runs only after the whole release succeeds. Creates a vX.Y branch for a + # new major/minor line (X.Y.0) and no-ops for patch releases; dry runs pass + # a ref instead of a version, so they never create a branch. + needs: [pre-publish, post-publish] + uses: ./.github/workflows/create-release-branch.yml + permissions: + id-token: write + contents: write + secrets: inherit + with: + version: ${{ needs.pre-publish.outputs.version }} + base_ref: ${{ needs.pre-publish.outputs.version }} From 442b07cb592b72f88515dc7edd8c6c7c1f8c6ab4 Mon Sep 17 00:00:00 2001 From: Iris Date: Tue, 24 Nov 2026 10:11:02 -0800 Subject: [PATCH 2/4] copilot feedback --- .github/workflows/create-release-branch.yml | 8 ++++++++ .github/workflows/release-python.yml | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml index e2b338a0db..5cc4b34d59 100644 --- a/.github/workflows/create-release-branch.yml +++ b/.github/workflows/create-release-branch.yml @@ -31,6 +31,13 @@ on: required: false type: string default: "true" + secrets: + APP_PRIVATE_KEY: + required: true + AWS_ROLE_ARN: + required: true + AWS_SECRET_ID: + required: true concurrency: group: create-branch-${{ github.ref }} @@ -43,6 +50,7 @@ defaults: jobs: release-branch: runs-on: ubuntu-latest + permissions: {} outputs: create: ${{ steps.compute.outputs.create }} branch_name: ${{ steps.compute.outputs.branch_name }} diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 572a4fa6cb..3401083b03 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -115,11 +115,14 @@ jobs: # new major/minor line (X.Y.0) and no-ops for patch releases; dry runs pass # a ref instead of a version, so they never create a branch. needs: [pre-publish, post-publish] - uses: ./.github/workflows/create-release-branch.yml + uses: $/.github/workflows/create-release-branch.yml permissions: id-token: write contents: write - secrets: inherit + secrets: + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + AWS_SECRET_ID: ${{ secrets.AWS_SECRET_ID }} with: version: ${{ needs.pre-publish.outputs.version }} base_ref: ${{ needs.pre-publish.outputs.version }} From 459bc0a52d2949f414c4205ea79564450b5f86c3 Mon Sep 17 00:00:00 2001 From: Iris Date: Tue, 24 Nov 2026 10:23:46 -0800 Subject: [PATCH 3/4] copilot feedback pt2 --- .github/workflows/create-release-branch.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml index 5cc4b34d59..65ddec7cb4 100644 --- a/.github/workflows/create-release-branch.yml +++ b/.github/workflows/create-release-branch.yml @@ -54,6 +54,7 @@ jobs: outputs: create: ${{ steps.compute.outputs.create }} branch_name: ${{ steps.compute.outputs.branch_name }} + branch_version: ${{ steps.compute.outputs.branch_version }} steps: - name: Compute the release branch name id: compute @@ -65,12 +66,16 @@ jobs: # A release branch is only created for a new major/minor line (X.Y.0); # an explicitly provided branch_name (manual dispatch) always wins. # Dry runs pass a ref rather than a version, so they never create branches. + # The branch is set to the next patch dev version (4.17.0 -> 4.17.1.dev0). if [ -n "$BRANCH_NAME" ]; then branch_name="$BRANCH_NAME" - elif [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.0$ ]]; then - branch_name="v$(echo "$VERSION" | cut -d. -f1-2)" + branch_version="$VERSION" + elif [[ "$VERSION" =~ ^([0-9]+)\.([0-9]+)\.0$ ]]; then + branch_name="v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}" + branch_version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.1.dev0" else branch_name="" + branch_version="" fi if [ -n "$branch_name" ]; then echo "create=true" >> "$GITHUB_OUTPUT" @@ -78,6 +83,7 @@ jobs: echo "create=false" >> "$GITHUB_OUTPUT" fi echo "branch_name=$branch_name" >> "$GITHUB_OUTPUT" + echo "branch_version=$branch_version" >> "$GITHUB_OUTPUT" create-branch: needs: release-branch @@ -125,7 +131,7 @@ jobs: id: create-branch with: branch_name: ${{ needs.release-branch.outputs.branch_name }} - version: ${{ inputs.version }} + version: ${{ needs.release-branch.outputs.branch_version }} base_ref: ${{ inputs.base_ref }} push_changes: ${{ inputs.push_changes }} version_bump_script: hatch version From 0e761c051b990e9464ab9914f795d1f7c8cec7c2 Mon Sep 17 00:00:00 2001 From: Iris Date: Wed, 25 Nov 2026 09:25:03 -0800 Subject: [PATCH 4/4] bump drivers-github-tools version --- .github/workflows/codeql.yml | 2 +- .github/workflows/create-release-branch.yml | 4 ++-- .github/workflows/release-python.yml | 12 ++++++------ .github/workflows/test-mod-wsgi.yml | 2 +- .github/workflows/test-python.yml | 16 ++++++++-------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 29d0f17113..720ec3070e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -37,7 +37,7 @@ jobs: - language: actions build-mode: none steps: - - uses: mongodb-labs/drivers-github-tools/codeql@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/codeql@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: language: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml index 65ddec7cb4..a12c620be2 100644 --- a/.github/workflows/create-release-branch.yml +++ b/.github/workflows/create-release-branch.yml @@ -119,7 +119,7 @@ jobs: run: | auth_header=$(printf 'x-access-token:%s' "${GH_TOKEN}" | base64 -w0) git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${auth_header}" - - uses: mongodb-labs/drivers-github-tools/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} aws_region_name: ${{ vars.AWS_REGION_NAME }} @@ -127,7 +127,7 @@ jobs: artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }} - name: Get hatch run: pip install hatch - - uses: mongodb-labs/drivers-github-tools/create-branch@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/create-branch@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 id: create-branch with: branch_name: ${{ needs.release-branch.outputs.branch_name }} diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 3401083b03..bf36b88b8f 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -38,16 +38,16 @@ jobs: outputs: version: ${{ steps.pre-publish.outputs.version }} steps: - - uses: mongodb-labs/drivers-github-tools/secure-checkout@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/secure-checkout@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: app_id: ${{ vars.APP_ID }} private_key: ${{ secrets.APP_PRIVATE_KEY }} - - uses: mongodb-labs/drivers-github-tools/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} aws_region_name: ${{ vars.AWS_REGION_NAME }} aws_secret_id: ${{ secrets.AWS_SECRET_ID }} - - uses: mongodb-labs/drivers-github-tools/python/pre-publish@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/python/pre-publish@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 id: pre-publish with: dry_run: ${{ env.DRY_RUN }} @@ -93,16 +93,16 @@ jobs: attestations: write security-events: write steps: - - uses: mongodb-labs/drivers-github-tools/secure-checkout@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/secure-checkout@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: app_id: ${{ vars.APP_ID }} private_key: ${{ secrets.APP_PRIVATE_KEY }} - - uses: mongodb-labs/drivers-github-tools/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} aws_region_name: ${{ vars.AWS_REGION_NAME }} aws_secret_id: ${{ secrets.AWS_SECRET_ID }} - - uses: mongodb-labs/drivers-github-tools/python/post-publish@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + - uses: mongodb-labs/drivers-github-tools/python/post-publish@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: following_version: ${{ env.FOLLOWING_VERSION }} product_name: ${{ env.PRODUCT_NAME }} diff --git a/.github/workflows/test-mod-wsgi.yml b/.github/workflows/test-mod-wsgi.yml index 990a645086..7f6f1da852 100644 --- a/.github/workflows/test-mod-wsgi.yml +++ b/.github/workflows/test-mod-wsgi.yml @@ -145,7 +145,7 @@ jobs: with: index: 1 - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: python-version: ${{ steps.versions.outputs.python-version }} - name: Install Apache diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index c103a0cbab..427a9e1b73 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -26,7 +26,7 @@ jobs: with: persist-credentials: false - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: python-version: "3.11" # Runs before the install so a stale lock fails in seconds rather than @@ -80,7 +80,7 @@ jobs: with: persist-credentials: false - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: # The beta Python here relies on the action's prerelease default. python-version: ${{ matrix.python-version }} @@ -103,7 +103,7 @@ jobs: persist-credentials: false submodules: true - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: python-version: "3.11" - id: setup-mongodb @@ -129,7 +129,7 @@ jobs: persist-credentials: false submodules: true - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: python-version: "3.11" - name: Install dependencies @@ -151,7 +151,7 @@ jobs: with: persist-credentials: false - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: python-version: "3.11" - name: Install dependencies @@ -170,7 +170,7 @@ jobs: with: persist-credentials: false - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: python-version: "${{matrix.python}}" - name: Install dependencies @@ -188,7 +188,7 @@ jobs: persist-credentials: false submodules: true - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: python-version: "3.11" - name: Install dependencies @@ -274,7 +274,7 @@ jobs: with: persist-credentials: false - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 + uses: mongodb-labs/drivers-github-tools/python/setup@034ec34103f5a8080e19e09af25f0f6b7597bf8a # v3.2.0 with: python-version: "3.11" - id: setup-mongodb