Skip to content

Commit b9ed42a

Browse files
Merge branch 'master' into jruby-10-compat
2 parents e10525b + 4049239 commit b9ed42a

File tree

8 files changed

+91
-179
lines changed

8 files changed

+91
-179
lines changed

.github/workflows/bson-ruby.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
rubocop:
77
runs-on: ubuntu-latest
88
env:
99
CI: true
1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
12+
1213
- name: Set up Ruby 3.4
1314
uses: ruby/setup-ruby@v1
1415
with:
@@ -34,27 +35,24 @@ jobs:
3435
fail-fast: false
3536
matrix:
3637
os: [ ubuntu, macos, windows ]
37-
ruby: [ 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, head ]
38+
ruby: [ 2.7, '3.0', 3.1, 3.2, 3.3, 3.4, head ]
3839
include:
39-
- { os: windows , ruby: mingw }
40+
- { os: windows , ruby: ucrt }
4041
exclude:
4142
- { os: windows , ruby: head }
42-
- { os: windows , ruby: 3.1 }
4343

4444
steps:
4545
- name: repo checkout
46-
uses: actions/checkout@v2
46+
uses: actions/checkout@v4
4747
with:
4848
submodules: recursive
4949

50-
- name: load ruby, ragel
50+
- name: load ruby
5151
uses: ruby/setup-ruby@v1
5252
with:
5353
ruby-version: ${{ matrix.ruby }}
54-
bundler: 2
55-
56-
- name: bundle install
57-
run: bundle install --jobs 4 --retry 3
54+
rubygems: latest
55+
bundler-cache: true
5856

5957
- name: compile
6058
run: bundle exec rake compile

.github/workflows/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
steps:
3737
- name: Checkout repository
3838
uses: actions/checkout@v4
39+
with:
40+
submodules: true
3941

4042
- name: Setup Ruby
4143
if: matrix.build-mode == 'manual'

.github/workflows/release.yml

Lines changed: 46 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,24 @@ name: "BSON Release"
22
run-name: "BSON 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: bson-ruby
15-
RELEASE_MESSAGE_TEMPLATE: |
16-
Version {0} of [BSON for Ruby](https://rubygems.org/gems/bson) is now available.
17-
18-
**Release Highlights**
19-
20-
TODO: one or more paragraphs describing important changes in this release
21-
22-
**Documentation**
23-
24-
Documentation is available at [MongoDB.com](https://www.mongodb.com/docs/ruby-driver/current/tutorials/bson/).
25-
26-
**Installation**
27-
28-
You may install this version via RubyGems, with:
29-
30-
gem install --version {0} bson
20+
GEM_NAME: bson
21+
PRODUCT_NAME: BSON for Ruby
22+
PRODUCT_ID: mongodb-ruby-driver
3123

3224
permissions:
3325
# required for all workflows
@@ -38,133 +30,63 @@ permissions:
3830

3931
# only required for workflows in private repositories
4032
actions: read
33+
pull-requests: read
4134
contents: write
4235

4336
# required by the mongodb-labs/drivers-github-tools/setup@v2 step
4437
# also required by `rubygems/release-gem`
4538
id-token: write
4639

4740
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
51+
4852
build:
4953
name: "Build Gems"
54+
needs: check
55+
environment: release
5056
runs-on: ubuntu-latest
5157
strategy:
5258
fail-fast: false
5359
matrix:
54-
ruby: [ '3.2', jruby ]
60+
ruby: [ 'ruby-3.2', 'jruby-9.4' ]
5561
steps:
56-
- name: Check out the repository
57-
uses: actions/checkout@v4
58-
59-
- name: Setup Ruby
60-
uses: ruby/setup-ruby@v1
61-
with:
62-
ruby-version: ${{ matrix.ruby }}
63-
bundler-cache: true
64-
65-
- name: Set output gem file name
66-
shell: bash
67-
run: |
68-
echo "GEM_FILE_NAME=$(bundle exec rake gem_file_name)" >> "$GITHUB_ENV"
69-
70-
- name: Build the gem
71-
shell: bash
72-
run: bundle exec rake build
73-
74-
- name: Save the generated gem file for later
75-
uses: actions/upload-artifact@v4
62+
- name: "Run the build action"
63+
uses: jamis/drivers-github-tools/ruby/build@ruby-3643-update-release-process
7664
with:
77-
name: ${{ env.GEM_FILE_NAME }}
78-
path: ${{ env.GEM_FILE_NAME }}
79-
retention-days: 1
80-
overwrite: true
65+
app_id: ${{ vars.APP_ID }}
66+
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
67+
artifact: ${{ matrix.ruby }}
68+
gem_name: ${{ env.GEM_NAME }}
69+
ruby_version: ${{ matrix.ruby }}
70+
ref: ${{ needs.check.outputs.ref }}
8171

8272
publish:
8373
name: Publish Gems
84-
needs: build
74+
needs: [ check, build ]
8575
environment: release
8676
runs-on: ubuntu-latest
8777
steps:
88-
- name: Check out the repository
89-
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
78+
- name: "Run the publish action"
79+
uses: jamis/drivers-github-tools/ruby/publish@ruby-3643-update-release-process
9080
with:
9181
app_id: ${{ vars.APP_ID }}
92-
private_key: ${{ secrets.APP_PRIVATE_KEY }}
93-
94-
- name: Setup Ruby
95-
uses: ruby/setup-ruby@v1
96-
with:
97-
ruby-version: '3.2'
98-
bundler-cache: true
99-
100-
- name: Get the release version
101-
shell: bash
102-
run: echo "RELEASE_VERSION=$(bundle exec rake version)" >> "$GITHUB_ENV"
103-
104-
- name: Setup GitHub tooling for DBX Drivers
105-
uses: mongodb-labs/drivers-github-tools/setup@v2
106-
with:
82+
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
10783
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
10884
aws_region_name: ${{ vars.AWS_REGION_NAME }}
10985
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
110-
111-
- name: Fetch the gem artifacts
112-
uses: actions/download-artifact@v4
113-
with:
114-
merge-multiple: true
115-
116-
- name: Sign the gems
117-
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
118-
with:
119-
filenames: '*.gem'
120-
121-
- name: Generate SSDLC Reports
122-
uses: mongodb-labs/drivers-github-tools/full-report@v2
123-
with:
124-
product_name: BSON for Ruby
125-
release_version: ${{ env.RELEASE_VERSION }}
126-
dist_filenames: '*.gem'
127-
silk_asset_group: bson-ruby
128-
129-
- name: Create the tag
130-
uses: mongodb-labs/drivers-github-tools/tag-version@v2
131-
with:
132-
version: ${{ env.RELEASE_VERSION }}
133-
tag_template: "v${VERSION}"
134-
tag_message_template: "Release tag for v${VERSION}"
135-
136-
- name: Create a new release
137-
shell: bash
138-
run: gh release create v${{ env.RELEASE_VERSION }} --title ${{ env.RELEASE_VERSION }} --generate-notes --draft
139-
140-
- name: Capture the changelog
141-
shell: bash
142-
run: gh release view v${{ env.RELEASE_VERSION }} --json body --template '{{ .body }}' >> changelog
143-
144-
- name: Prepare release message
145-
shell: bash
146-
run: |
147-
echo "${{ format(env.RELEASE_MESSAGE_TEMPLATE, env.RELEASE_VERSION) }}" > release-message
148-
cat changelog >> release-message
149-
150-
- name: Update release information
151-
shell: bash
152-
run: |
153-
echo "RELEASE_URL=$(gh release edit v${{ env.RELEASE_VERSION }} --notes-file release-message)" >> "$GITHUB_ENV"
154-
155-
- name: Upload release artifacts
156-
shell: bash
157-
run: gh release upload v${{ env.RELEASE_VERSION }} *.gem ${{ env.RELEASE_ASSETS }}/*.sig
158-
159-
- name: Upload S3 assets
160-
uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
161-
with:
162-
version: ${{ env.RELEASE_VERSION }}
163-
product_name: 'bson-ruby'
164-
dry_run: ${{ inputs.dry_run }}
165-
166-
- name: Publish the gems
167-
uses: rubygems/release-gem@v1
168-
if: inputs.dry_run == false
169-
with:
170-
await-release: false
86+
dry_run: false
87+
gem_name: ${{ env.GEM_NAME }}
88+
product_name: ${{ env.PRODUCT_NAME }}
89+
product_id: ${{ env.PRODUCT_ID }}
90+
release_message: ${{ needs.check.outputs.message }}
91+
silk_asset_group: ${{ env.SILK_ASSET_GROUP }}
92+
ref: ${{ needs.check.outputs.ref }}

Rakefile

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ require "rake/extensiontask"
2525
require "rspec/core/rake_task"
2626
require 'fileutils'
2727

28+
if File.exist?('./spec/shared/lib/tasks/candidate.rake')
29+
load './spec/shared/lib/tasks/candidate.rake'
30+
end
31+
2832
def jruby?
2933
defined?(JRUBY_VERSION)
3034
end
@@ -51,8 +55,10 @@ RSpec::Core::RakeTask.new(:rspec)
5155

5256
desc 'Build the bson gem'
5357
task :build => [ :clean_all, *(jruby? ? :compile : nil) ] do
54-
output = "--output=#{ENV['GEM_FILE_NAME']}" if ENV['GEM_FILE_NAME']
55-
system "gem build #{output} bson.gemspec"
58+
command = [ 'gem', 'build' ]
59+
command << "--output=#{ENV['GEM_FILE_NAME']}" if ENV['GEM_FILE_NAME']
60+
command << ENV['GEMSPEC'] || 'bson.gemspec'
61+
system(*command)
5662
end
5763

5864
# `rake version` is used by the deployment system so get the release version
@@ -64,22 +70,10 @@ task :version do
6470
puts BSON::VERSION
6571
end
6672

67-
# `rake gem_file_name` is used by the deployment system so get the name of
68-
# the gem file to be generated. It must do nothing more than just print the
69-
# name of the gem file to generate.
70-
desc 'Print the name of the gem file to generate.'
71-
task :gem_file_name do
72-
require 'bson/version'
73-
base = "bson-#{BSON::VERSION}"
74-
base << '-java' if jruby?
75-
puts "#{base}.gem"
76-
end
77-
7873
task :clean_all => :clean do
79-
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.bundle"))
80-
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.so"))
81-
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.o"))
82-
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson-ruby.jar"))
74+
%w[ bson-ruby.jar bson_native.bundle bson_native.so bson_native.o ].each do |file|
75+
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', file))
76+
end
8377
end
8478

8579
task :spec => :compile do
@@ -91,15 +85,6 @@ end
9185
# been built (and signed via GPG), so we just need `rake release` to
9286
# push the gem to rubygems.
9387
task :release do
94-
require 'bson/version'
95-
96-
# confirm: there ought to be two gems, one for MRI, and one for Java. These
97-
# will have been previously generated by the 'BSON Release' GitHub action.
98-
gems = Dir['*.gem']
99-
if gems.length != 2
100-
abort "Expected two gem files to be ready to release; got #{gems.length}"
101-
end
102-
10388
if ENV['GITHUB_ACTION'].nil?
10489
abort <<~WARNING
10590
`rake release` must be invoked from the `BSON Release` GitHub action,
@@ -114,6 +99,13 @@ task :release do
11499
WARNING
115100
end
116101

102+
# confirm: there ought to be two gems, one for MRI, and one for Java. These
103+
# will have been previously generated by the 'build' job.
104+
gems = Dir['*.gem']
105+
if gems.length != 2
106+
abort "Expected two gem files to be ready to release; got #{gems.inspect}"
107+
end
108+
117109
gems.each do |gem|
118110
system 'gem', 'push', gem
119111
end

ext/bson/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
require 'mkmf'
55

6-
$CFLAGS << ' -Wall -g -std=c99'
6+
append_cflags(["-Wall", "-g", "-std=c99"])
77

88
create_makefile('bson_native')

lib/bson/version.rb

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
# frozen_string_literal: true
2-
# rubocop:todo all
3-
4-
# Copyright (C) 2009-2020 MongoDB Inc.
5-
#
6-
# Licensed under the Apache License, Version 2.0 (the "License");
7-
# you may not use this file except in compliance with the License.
8-
# You may obtain a copy of the License at
9-
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
12-
# Unless required by applicable law or agreed to in writing, software
13-
# distributed under the License is distributed on an "AS IS" BASIS,
14-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
# See the License for the specific language governing permissions and
16-
# limitations under the License.
172

183
module BSON
19-
VERSION = "5.0.2"
4+
# The current version of the library.
5+
#
6+
# NOTE: this file is automatically updated via `rake candidate:create`.
7+
# Manual changes to this file may be overwritten by that rake task.
8+
VERSION = '5.1.1'
209
end

product.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: BSON for Ruby
3+
description: a fully featured [BSON specification](https://bsonspec.org/) implementation
4+
in Ruby
5+
package: bson
6+
jira: https://jira.mongodb.org/projects/RUBY
7+
version:
8+
number: 5.1.1
9+
file: lib/bson/version.rb

0 commit comments

Comments
 (0)