Skip to content

Commit

Permalink
Merge branch 'master' into 3414-fix-serverless-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
comandeo-mongo committed Jun 17, 2024
2 parents 90006c1 + 9c709b9 commit 0c9c5e8
Show file tree
Hide file tree
Showing 19 changed files with 422 additions and 249 deletions.
67 changes: 0 additions & 67 deletions .evergreen/tools.rb

This file was deleted.

4 changes: 4 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# For configuring how release notes are auto-generated.
# Requires the use of labels to categorize pull requests.
#
# See: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
77 changes: 77 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: '20 0 * * 0'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: 'ubuntu-latest'
timeout-minutes: 360
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: read

strategy:
fail-fast: false
matrix:
include:
- language: ruby
build-mode: none
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
config: |
paths-ignore:
- .evergreen
- spec
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
130 changes: 130 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: "Driver Release"
run-name: "Ruby Driver Release ${{ github.ref_name }}"

on: workflow_dispatch

env:
RELEASE_MESSAGE_TEMPLATE: |
Version {0} of the [MongoDB Ruby Driver](https://rubygems.org/gems/mongo) is now available.
**Release Highlights**
TODO: one or more paragraphs describing important changes in this release
**Documentation**
Documentation is available at [MongoDB.com](https://www.mongodb.com/docs/ruby-driver/current/).
**Installation**
You may install this version via RubyGems, with:
gem install --version {0} mongo
jobs:
release:
name: "Driver Release"
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: "Create temporary app token"
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}

- name: "Store GitHub token in environment"
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
shell: bash

- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: Setup GitHub tooling for DBX Drivers
uses: mongodb-labs/drivers-github-tools/setup@v2
with:
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
aws_region_name: ${{ vars.AWS_REGION_NAME }}
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}

- name: Get the driver version
shell: bash
run: |
echo "DRIVER_VERSION=$(ruby -Ilib -rmongo/version -e 'puts Mongo::VERSION')" >> "$GITHUB_ENV"
- name: Set output gem file name
shell: bash
run: |
echo "GEM_FILE_NAME=mongo-${{ env.DRIVER_VERSION }}.gem" >> "$GITHUB_ENV"
- name: Build the gem
shell: bash
run: |
gem build --output=${{ env.GEM_FILE_NAME }} mongo.gemspec
- name: Sign the gem
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
with:
filenames: '${{ env.GEM_FILE_NAME }}'

- name: Create and sign the tag
uses: mongodb-labs/drivers-github-tools/git-sign@v2
with:
command: "git tag -u ${{ env.GPG_KEY_ID }} -m 'Release tag for v${{ env.DRIVER_VERSION }}' v${{ env.DRIVER_VERSION }}"

- name: Push the tag to the repository
shell: bash
run: |
git push origin v${{ env.DRIVER_VERSION }}
- name: Create a new release
shell: bash
run: gh release create v${{ env.DRIVER_VERSION }} --title ${{ env.DRIVER_VERSION }} --generate-notes --draft

- name: Capture the changelog
shell: bash
run: gh release view v${{ env.DRIVER_VERSION }} --json body --template '{{ .body }}' >> changelog

- name: Prepare release message
shell: bash
run: |
echo "${{ format(env.RELEASE_MESSAGE_TEMPLATE, env.DRIVER_VERSION) }}" > release-message
cat changelog >> release-message
- name: Update release information
shell: bash
run: |
echo "RELEASE_URL=$(gh release edit v${{ env.DRIVER_VERSION }} --notes-file release-message)" >> "$GITHUB_ENV"
- name: Upload release artifacts
run: gh release upload v${{ env.DRIVER_VERSION }} ${{ env.GEM_FILE_NAME }} ${{ env.RELEASE_ASSETS }}/${{ env.GEM_FILE_NAME }}.sig

- name: Publish the gem
uses: rubygems/release-gem@v1
with:
await-release: false
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,43 @@ MongoDB Ruby Driver

The officially supported Ruby driver for [MongoDB](https://www.mongodb.org/).

The Ruby driver supports Ruby 2.5-3.0 and JRuby 9.2.
The Ruby driver supports Ruby 2.7-3.3 and JRuby 9.3-9.4.

## Installation

Install via RubyGems, either via the command-line for ad-hoc uses:

$ gem install mongo

Or via a Gemfile for more general use:

gem 'mongo'

### Release Integrity

Each release of the MongoDB Ruby driver after version 2.20.0 has been automatically built and signed using the team's GPG key.

To verify the driver's gem file:

1. [Download the GPG key](https://pgp.mongodb.com/ruby-driver.asc).
2. Import the key into your GPG keyring with `gpg --import ruby-driver.asc`.
3. Download the gem file (if you don't already have it). You can download it from RubyGems with `gem fetch mongo`, or you can download it from the [releases page](https://github.com/mongodb/mongo-ruby-driver/releases) on GitHub.
4. Download the corresponding detached signature file from the [same release](https://github.com/mongodb/mongo-ruby-driver/releases). Look at the bottom of the release that corresponds to the gem file, under the 'Assets' list, for a `.sig` file with the same version number as the gem you wish to install.
5. Verify the gem with `gpg --verify mongo-X.Y.Z.gem.sig mongo-X.Y.Z.gem` (replacing `X.Y.Z` with the actual version number).

You are looking for text like "Good signature from "MongoDB Ruby Driver Release Signing Key <[email protected]>" in the output. If you see that, the signature was found to correspond to the given gem file.

(Note that other output, like "This key is not certified with a trusted signature!", is related to *web of trust* and depends on how strongly you, personally, trust the `ruby-driver.asc` key that you downloaded from us. To learn more, see https://www.gnupg.org/gph/en/manual/x334.html)

### Why not use RubyGems' gem-signing functionality?

RubyGems' own gem signing is problematic, most significantly because there is no established chain of trust related to the keys used to sign gems. RubyGems' own documentation admits that "this method of signing gems is not widely used" (see https://guides.rubygems.org/security/). Discussions about this in the RubyGems community have been off-and-on for more than a decade, and while a solution will eventually arrive, we have settled on using GPG instead for the following reasons:

1. Many of the other driver teams at MongoDB are using GPG to sign their product releases. Consistency with the other teams means that we can reuse existing tooling for our own product releases.
2. GPG is widely available and has existing tools and procedures for dealing with web of trust (though they are admittedly quite arcane and intimidating to the uninitiated, unfortunately).

Ultimately, most users do not bother to verify gems, and will not be impacted by our choice of GPG over RubyGems' native method.


## Documentation

Expand Down
Loading

0 comments on commit 0c9c5e8

Please sign in to comment.