From e5718b8b6aa320f667e24ba68236f0e56da6fb91 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 24 Jun 2025 10:57:46 -0600 Subject: [PATCH 1/3] RUBY-3410 Release automation (#2935) * use new candidate tasks for release management * update the release workflow * don't load candidate rake tasks if the file isn't there this prevents us from having to load submodules during the release process, just to pick up tasks that aren't needed. * Let the build task create the gem * bump spec/shared for candidate code update * use the push & workflow_dispatch triggers * add the product.yml file * fix typo in release.yml --- .github/workflows/release.yml | 103 ++++++++++++++++++++-------------- Rakefile | 18 +++--- lib/mongo/version.rb | 17 +----- product.yml | 8 +++ spec/shared | 2 +- 5 files changed, 83 insertions(+), 65 deletions(-) create mode 100644 product.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1232eb9e5e..fbaf66a533 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,67 +1,88 @@ -name: "Driver Release" -run-name: "Driver Release for ${{ github.ref }}" +name: "Gem Release" +run-name: "Gem Release for ${{ github.ref }}" on: + # for auto-deploy when merging a release-candidate PR + push: + branches: + - 'master' + - '*-stable' + + # for manual release workflow_dispatch: inputs: - dry_run: - description: Whether this is a dry run or not + pr: + description: "The number of the merged release candidate PR" required: true - default: true - type: boolean env: SILK_ASSET_GROUP: mongodb-ruby-driver - RELEASE_MESSAGE_TEMPLATE: | - Version {0} of the [MongoDB Ruby Driver](https://rubygems.org/gems/mongo) is now available. - - **Release Highlights** + GEM_NAME: mongo + PRODUCT_NAME: Ruby Driver + PRODUCT_ID: mongodb-ruby-driver - TODO: one or more paragraphs describing important changes in this release +permissions: + # required for all workflows + security-events: write - **Documentation** + # required to fetch internal or private CodeQL packs + packages: read - Documentation is available at [MongoDB.com](https://www.mongodb.com/docs/ruby-driver/current/). + # only required for workflows in private repositories + actions: read + pull-requests: read + contents: write - **Installation** + # required by the mongodb-labs/drivers-github-tools/setup@v2 step + # also required by `rubygems/release-gem` + id-token: write - You may install this version via RubyGems, with: +jobs: + check: + name: "Check Release" + runs-on: ubuntu-latest + outputs: + message: ${{ steps.check.outputs.message }} + ref: ${{ steps.check.outputs.ref }} + steps: + - name: "Run the check action" + id: check + uses: jamis/drivers-github-tools/ruby/pr-check@ruby-3643-update-release-process - gem install --version {0} mongo + build: + name: "Build Gems" + needs: check + environment: release + runs-on: ubuntu-latest + steps: + - name: "Run the build action" + uses: jamis/drivers-github-tools/ruby/build@ruby-3643-update-release-process + with: + app_id: ${{ vars.APP_ID }} + app_private_key: ${{ secrets.APP_PRIVATE_KEY }} + artifact: 'ruby-3.2' + gem_name: ${{ env.GEM_NAME }} + ruby_version: 'ruby-3.2' + ref: ${{ needs.check.outputs.ref }} -jobs: - release: - name: "Driver Release" + publish: + name: "Publish Gems" + needs: [ check, build ] environment: release runs-on: 'ubuntu-latest' - - permissions: - # required for all workflows - security-events: write - - # required to fetch internal or private CodeQL packs - packages: read - - # only required for workflows in private repositories - actions: read - contents: write - - # required by the mongodb-labs/drivers-github-tools/setup@v2 step - # also required by `rubygems/release-gem` - id-token: write - steps: - name: "Run the publish action" - uses: mongodb-labs/drivers-github-tools/ruby/publish@v2 + uses: jamis/drivers-github-tools/ruby/publish@ruby-3643-update-release-process with: app_id: ${{ vars.APP_ID }} app_private_key: ${{ secrets.APP_PRIVATE_KEY }} aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} aws_region_name: ${{ vars.AWS_REGION_NAME }} aws_secret_id: ${{ secrets.AWS_SECRET_ID }} - dry_run: ${{ inputs.dry_run }} - gem_name: mongo - product_name: Ruby Driver - product_id: mongodb-ruby-driver - release_message_template: ${{ env.RELEASE_MESSAGE_TEMPLATE }} + dry_run: false + gem_name: ${{ env.GEM_NAME }} + product_name: ${{ env.PRODUCT_NAME }} + product_id: ${{ env.PRODUCT_ID }} + release_message: ${{ needs.check.outputs.message }} silk_asset_group: ${{ env.SILK_ASSET_GROUP }} + ref: ${{ needs.check.outputs.ref }} diff --git a/Rakefile b/Rakefile index 1c9c2ff8cc..4dae9eb40a 100644 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,10 @@ require 'bundler' require 'rspec/core/rake_task' +if File.exist?('./spec/shared/lib/tasks/candidate.rake') + load 'spec/shared/lib/tasks/candidate.rake' +end + ROOT = File.expand_path(File.join(File.dirname(__FILE__))) $: << File.join(ROOT, 'spec/shared/lib') @@ -34,16 +38,12 @@ end task :default => ['spec:prepare', :spec] -# stands in for the Bundler-provided `build` task, which builds the -# gem for this project. Our release process builds the gems in a -# particular way, in a GitHub action. This task is just to help remind -# developers of that fact. +desc 'Build the gem' task :build do - abort <<~WARNING - `rake build` does nothing in this project. The gem must be built via - the `Driver Release` action on GitHub, which is triggered manually when - a new release is ready. - WARNING + command = %w[ gem build ] + command << "--output=#{ENV['GEM_FILE_NAME']}" if ENV['GEM_FILE_NAME'] + command << (ENV['GEMSPEC'] || 'mongo.gemspec') + system(*command) end # `rake version` is used by the deployment system so get the release version diff --git a/lib/mongo/version.rb b/lib/mongo/version.rb index df2b2a7904..0932949f1c 100644 --- a/lib/mongo/version.rb +++ b/lib/mongo/version.rb @@ -1,20 +1,9 @@ # frozen_string_literal: true -# Copyright (C) 2014-2020 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - module Mongo # The current version of the driver. + # + # Note that this file is automatically updated via `rake candidate:create`. + # Manual changes to this file will be overwritten by that rake task. VERSION = '2.20.1' end diff --git a/product.yml b/product.yml new file mode 100644 index 0000000000..d5c5f3c76b --- /dev/null +++ b/product.yml @@ -0,0 +1,8 @@ +--- +name: MongoDB Ruby Driver +description: a pure-Ruby driver for connecting to, querying, and manipulating MongoDB databases +package: mongo +jira: https://jira.mongodb.org/projects/RUBY +version: + number: 2.21.1 + file: lib/mongo/version.rb diff --git a/spec/shared b/spec/shared index cee4bc0264..a59235a9fd 160000 --- a/spec/shared +++ b/spec/shared @@ -1 +1 @@ -Subproject commit cee4bc02649a573c8256b0505c1d23f503ac2609 +Subproject commit a59235a9fd96c545105f8f1f9dec49738e1c0a3c From b19818feaa215afc4b33cd150fac46807d35c748 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Fri, 8 Aug 2025 14:16:03 -0600 Subject: [PATCH 2/3] fix version number for 2.20-stable --- product.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product.yml b/product.yml index d5c5f3c76b..1c96747e11 100644 --- a/product.yml +++ b/product.yml @@ -4,5 +4,5 @@ description: a pure-Ruby driver for connecting to, querying, and manipulating Mo package: mongo jira: https://jira.mongodb.org/projects/RUBY version: - number: 2.21.1 + number: 2.20.1 file: lib/mongo/version.rb From 893208f2b34171fa2e49cfd965fdb69c03317f27 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Fri, 8 Aug 2025 14:24:03 -0600 Subject: [PATCH 3/3] bump to latest spec/shared for most recent candidate task changes --- spec/shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/shared b/spec/shared index a59235a9fd..f1c563a36c 160000 --- a/spec/shared +++ b/spec/shared @@ -1 +1 @@ -Subproject commit a59235a9fd96c545105f8f1f9dec49738e1c0a3c +Subproject commit f1c563a36ce64541331fdbc9afe3c27d2b9e2463