Skip to content

Commit 0e007f5

Browse files
feat(NODE-6158): add signature to github releases (#37)
1 parent cb63628 commit 0e007f5

File tree

3 files changed

+91
-8
lines changed

3 files changed

+91
-8
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Compress and Sign
2+
description: 'Compresses package and signs with garasign'
3+
4+
inputs:
5+
aws_role_arn:
6+
description: 'AWS role input for drivers-github-tools/gpg-sign@v2'
7+
required: true
8+
aws_region_name:
9+
description: 'AWS region name input for drivers-github-tools/gpg-sign@v2'
10+
required: true
11+
aws_secret_id:
12+
description: 'AWS secret id input for drivers-github-tools/gpg-sign@v2'
13+
required: true
14+
npm_package_name:
15+
description: 'The name for the npm package this repository represents'
16+
required: true
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- run: npm pack
22+
shell: bash
23+
24+
- name: Get release version and release package file name
25+
id: get_vars
26+
shell: bash
27+
run: |
28+
package_version=$(jq --raw-output '.version' package.json)
29+
echo "package_version=${package_version}" >> "$GITHUB_OUTPUT"
30+
echo "package_file=${{ inputs.npm_package_name }}-${package_version}.tgz" >> "$GITHUB_OUTPUT"
31+
32+
- name: Set up drivers-github-tools
33+
uses: mongodb-labs/drivers-github-tools/setup@v2
34+
with:
35+
aws_region_name: ${{ inputs.aws_region_name }}
36+
aws_role_arn: ${{ inputs.aws_role_arn }}
37+
aws_secret_id: ${{ inputs.aws_secret_id }}
38+
39+
- name: Create detached signature
40+
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
41+
with:
42+
filenames: ${{ steps.get_vars.outputs.package_file }}
43+
env:
44+
RELEASE_ASSETS: ${{ steps.get_vars.outputs.package_file }}.temp.sig
45+
46+
- name: Name release asset correctly
47+
run: mv ${{ steps.get_vars.outputs.package_file }}.temp.sig ${{ steps.get_vars.outputs.package_file }}.sig
48+
shell: bash
49+
50+
- name: "Upload release artifacts"
51+
run: gh release upload v${{ steps.get_vars.outputs.package_version }} ${{ steps.get_vars.outputs.package_file }}.sig
52+
shell: bash
53+
env:
54+
GH_TOKEN: ${{ github.token }}

.github/workflows/release.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,30 @@ permissions:
1111
name: release
1212

1313
jobs:
14-
release-please:
14+
release_please:
1515
runs-on: ubuntu-latest
16+
outputs:
17+
release_created: ${{ steps.release.outputs.release_created }}
1618
steps:
1719
- id: release
1820
uses: googleapis/release-please-action@v4
1921

20-
# If release-please created a release, publish to npm
21-
- if: ${{ steps.release.outputs.release_created }}
22-
uses: actions/checkout@v4
23-
- if: ${{ steps.release.outputs.release_created }}
24-
name: actions/setup
22+
compress_sign_and_upload:
23+
needs: [release_please]
24+
if: ${{ needs.release_please.outputs.release_created }}
25+
environment: release
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: actions/setup
2530
uses: ./.github/actions/setup
26-
- if: ${{ steps.release.outputs.release_created }}
27-
run: npm publish --provenance
31+
- name: actions/compress_sign_and_upload
32+
uses: ./.github/actions/compress_sign_and_upload
33+
with:
34+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
35+
aws_region_name: 'us-east-1'
36+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
37+
npm_package_name: 'mongodb-legacy'
38+
- run: npm publish --provenance
2839
env:
2940
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,24 @@ In your existing project add `mongodb-legacy` to your `package.json` with the fo
6262
npm install mongodb-legacy
6363
```
6464

65+
66+
### Release Integrity
67+
68+
The GitHub release contains a detached signature file for the NPM package (named
69+
`mongodb-legacy-X.Y.Z.tgz.sig`).
70+
71+
The following command returns the link npm package.
72+
```shell
73+
npm view [email protected] dist.tarball
74+
```
75+
76+
Using the result of the above command, a `curl` command can return the official npm package for the release.
77+
78+
To verify the integrity of the downloaded package, run the following command:
79+
```shell
80+
gpg --verify mongodb-legacy-X.Y.Z.tgz.sig mongodb-legacy-X.Y.Z.tgz
81+
```
82+
6583
### Versioning
6684

6785
We recommend replacing your `mongodb` dependency with this one.

0 commit comments

Comments
 (0)