Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NODE-6156): add signature to github releases #692

Merged
merged 25 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/actions/compress_sign_and_upload/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Compress and Sign
description: 'Compresses package and signs with garasign'

inputs:
garasign_username:
description: 'Garasign username input for drivers-github-tools/garasign/gpg-sign'
required: true
garasign_password:
description: 'Garasign password input for drivers-github-tools/garasign/gpg-sign'
required: true
artifactory_username:
description: 'Artifactory username input for drivers-github-tools/garasign/gpg-sign'
required: true
artifactory_password:
description: 'Artifactory password input for drivers-github-tools/garasign/gpg-sign'
required: true

runs:
using: composite
steps:
- run: npm pack
shell: bash

- name: Get release version and release package file name
id: vars
shell: bash
run: |
package_version=$(jq --raw-output '.version' package.json)
echo "package_version=${package_version}" >> "$GITHUB_OUTPUT"
echo "package_file=bson-${package_version}.tgz" >> "$GITHUB_OUTPUT"

- name: Create detached signature
uses: mongodb-labs/drivers-github-tools/garasign/gpg-sign@v1
with:
filenames: ${{ steps.vars.package_file }}
garasign_username: ${{ inputs.garasign_username }}
garasign_password: ${{ inputs.garasign_password }}
artifactory_username: ${{ inputs.artifactory_username }}
artifactory_password: ${{ inputs.artifactory_password }}

- name: "Upload release artifacts"
run: gh release upload v${{ steps.vars.package_version }} ${{ steps.vars.package_file }}.sig
shell: bash
27 changes: 18 additions & 9 deletions .github/workflows/release-5.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,30 @@ permissions:
name: release-5x

jobs:
release-please:
release_please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- id: release
uses: google-github-actions/release-please-action@v4
with:
target-branch: 5.x

# If release-please created a release, publish to npm
- if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4
- if: ${{ steps.release.outputs.release_created }}
name: actions/setup

compress-sign-and-upload:
needs: [release_please]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: actions/setup
uses: ./.github/actions/setup
- if: ${{ steps.release.outputs.release_created }}
run: npm publish --provenance --tag=5x
- name: actions/compress_sign_and_upload
uses: ./.github/actions/compress_sign_and_upload
with:
garasign_username: ${{ secrets.GRS_CONFIG_USER1_USERNAME }}
garasign_password: ${{ secrets.GRS_CONFIG_USER1_PASSWORD }}
artifactory_username: ${{ secrets.ARTIFACTORY_USER }}
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
- run: npm publish --provenance --tag=5x
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
25 changes: 17 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,28 @@ permissions:
name: release

jobs:
release-please:
release_please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- id: release
uses: google-github-actions/release-please-action@v4

# If release-please created a release, publish to npm
- if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4
- if: ${{ steps.release.outputs.release_created }}
name: actions/setup
compress_sign_and_upload:
needs: [release_please]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: actions/setup
uses: ./.github/actions/setup
- if: ${{ steps.release.outputs.release_created }}
run: npm publish --provenance
- name: actions/compress_sign_and_upload
uses: ./.github/actions/compress_sign_and_upload
with:
garasign_username: ${{ secrets.GRS_CONFIG_USER1_USERNAME }}
garasign_password: ${{ secrets.GRS_CONFIG_USER1_PASSWORD }}
artifactory_username: ${{ secrets.ARTIFACTORY_USER }}
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ You can learn more about it in [the specification](http://bsonspec.org).
- [Documentation](#documentation)
- [FAQ](#faq)


### Release Integrity

The GitHub release contains a detached signature file for the NPM package (named
`bson-X.Y.Z.tgz.sig`).

The following command returns the link npm package.
```shell
npm view [email protected] dist.tarball
```

Using the result of the above command, a `curl` command can return the official npm package for the release.

To verify the integrity of the downloaded package, run the following command:
```shell
gpg --verify bson-X.Y.Z.tgz.sig bson-X.Y.Z.tgz
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved
```


## Bugs / Feature Requests

Think you've found a bug? Want to see a new feature in `bson`? Please open a case in our issue management tool, JIRA:
Expand Down