Skip to content

Commit e741df4

Browse files
authored
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
1 parent 4c16a1c commit e741df4

File tree

5 files changed

+83
-65
lines changed

5 files changed

+83
-65
lines changed

.github/workflows/release.yml

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,88 @@
1-
name: "Driver Release"
2-
run-name: "Driver Release for ${{ github.ref }}"
1+
name: "Gem Release"
2+
run-name: "Gem Release for ${{ github.ref }}"
33

44
on:
5+
# for auto-deploy when merging a release-candidate PR
6+
push:
7+
branches:
8+
- 'master'
9+
- '*-stable'
10+
11+
# for manual release
512
workflow_dispatch:
613
inputs:
7-
dry_run:
8-
description: Whether this is a dry run or not
14+
pr:
15+
description: "The number of the merged release candidate PR"
916
required: true
10-
default: true
11-
type: boolean
1217

1318
env:
1419
SILK_ASSET_GROUP: mongodb-ruby-driver
15-
RELEASE_MESSAGE_TEMPLATE: |
16-
Version {0} of the [MongoDB Ruby Driver](https://rubygems.org/gems/mongo) is now available.
17-
18-
**Release Highlights**
20+
GEM_NAME: mongo
21+
PRODUCT_NAME: Ruby Driver
22+
PRODUCT_ID: mongodb-ruby-driver
1923

20-
TODO: one or more paragraphs describing important changes in this release
24+
permissions:
25+
# required for all workflows
26+
security-events: write
2127

22-
**Documentation**
28+
# required to fetch internal or private CodeQL packs
29+
packages: read
2330

24-
Documentation is available at [MongoDB.com](https://www.mongodb.com/docs/ruby-driver/current/).
31+
# only required for workflows in private repositories
32+
actions: read
33+
pull-requests: read
34+
contents: write
2535

26-
**Installation**
36+
# required by the mongodb-labs/drivers-github-tools/setup@v2 step
37+
# also required by `rubygems/release-gem`
38+
id-token: write
2739

28-
You may install this version via RubyGems, with:
40+
jobs:
41+
check:
42+
name: "Check Release"
43+
runs-on: ubuntu-latest
44+
outputs:
45+
message: ${{ steps.check.outputs.message }}
46+
ref: ${{ steps.check.outputs.ref }}
47+
steps:
48+
- name: "Run the check action"
49+
id: check
50+
uses: jamis/drivers-github-tools/ruby/pr-check@ruby-3643-update-release-process
2951

30-
gem install --version {0} mongo
52+
build:
53+
name: "Build Gems"
54+
needs: check
55+
environment: release
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: "Run the build action"
59+
uses: jamis/drivers-github-tools/ruby/build@ruby-3643-update-release-process
60+
with:
61+
app_id: ${{ vars.APP_ID }}
62+
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
63+
artifact: 'ruby-3.2'
64+
gem_name: ${{ env.GEM_NAME }}
65+
ruby_version: 'ruby-3.2'
66+
ref: ${{ needs.check.outputs.ref }}
3167

32-
jobs:
33-
release:
34-
name: "Driver Release"
68+
publish:
69+
name: "Publish Gems"
70+
needs: [ check, build ]
3571
environment: release
3672
runs-on: 'ubuntu-latest'
37-
38-
permissions:
39-
# required for all workflows
40-
security-events: write
41-
42-
# required to fetch internal or private CodeQL packs
43-
packages: read
44-
45-
# only required for workflows in private repositories
46-
actions: read
47-
contents: write
48-
49-
# required by the mongodb-labs/drivers-github-tools/setup@v2 step
50-
# also required by `rubygems/release-gem`
51-
id-token: write
52-
5373
steps:
5474
- name: "Run the publish action"
55-
uses: mongodb-labs/drivers-github-tools/ruby/publish@v2
75+
uses: jamis/drivers-github-tools/ruby/publish@ruby-3643-update-release-process
5676
with:
5777
app_id: ${{ vars.APP_ID }}
5878
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
5979
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
6080
aws_region_name: ${{ vars.AWS_REGION_NAME }}
6181
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
62-
dry_run: ${{ inputs.dry_run }}
63-
gem_name: mongo
64-
product_name: Ruby Driver
65-
product_id: mongodb-ruby-driver
66-
release_message_template: ${{ env.RELEASE_MESSAGE_TEMPLATE }}
82+
dry_run: false
83+
gem_name: ${{ env.GEM_NAME }}
84+
product_name: ${{ env.PRODUCT_NAME }}
85+
product_id: ${{ env.PRODUCT_ID }}
86+
release_message: ${{ needs.check.outputs.message }}
6787
silk_asset_group: ${{ env.SILK_ASSET_GROUP }}
88+
ref: ${{ needs.check.outputs.ref }}

Rakefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
require 'bundler'
55
require 'rspec/core/rake_task'
66

7+
if File.exist?('./spec/shared/lib/tasks/candidate.rake')
8+
load 'spec/shared/lib/tasks/candidate.rake'
9+
end
10+
711
ROOT = File.expand_path(File.join(File.dirname(__FILE__)))
812

913
$: << File.join(ROOT, 'spec/shared/lib')
@@ -34,16 +38,12 @@ end
3438

3539
task :default => ['spec:prepare', :spec]
3640

37-
# stands in for the Bundler-provided `build` task, which builds the
38-
# gem for this project. Our release process builds the gems in a
39-
# particular way, in a GitHub action. This task is just to help remind
40-
# developers of that fact.
41+
desc 'Build the gem'
4142
task :build do
42-
abort <<~WARNING
43-
`rake build` does nothing in this project. The gem must be built via
44-
the `Driver Release` action on GitHub, which is triggered manually when
45-
a new release is ready.
46-
WARNING
43+
command = %w[ gem build ]
44+
command << "--output=#{ENV['GEM_FILE_NAME']}" if ENV['GEM_FILE_NAME']
45+
command << (ENV['GEMSPEC'] || 'mongo.gemspec')
46+
system(*command)
4747
end
4848

4949
# `rake version` is used by the deployment system so get the release version

lib/mongo/version.rb

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
# frozen_string_literal: true
22

3-
# Copyright (C) 2014-2020 MongoDB Inc.
4-
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
16-
173
module Mongo
184
# The current version of the driver.
5+
#
6+
# Note that this file is automatically updated via `rake candidate:create`.
7+
# Manual changes to this file will be overwritten by that rake task.
198
VERSION = '2.21.1'
209
end

product.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: MongoDB Ruby Driver
3+
description: a pure-Ruby driver for connecting to, querying, and manipulating MongoDB databases
4+
package: mongo
5+
jira: https://jira.mongodb.org/projects/RUBY
6+
version:
7+
number: 2.21.1
8+
file: lib/mongo/version.rb

0 commit comments

Comments
 (0)