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-6161): Sign Releases #177

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
13f958b
feat(NODE-6161): sign kerberos releases
aditi-khare-mongoDB May 29, 2024
c2af477
fix tar sign
aditi-khare-mongoDB Jun 6, 2024
ff96c3b
add build steps
aditi-khare-mongoDB Jun 7, 2024
651755e
fix inputs
aditi-khare-mongoDB Jun 7, 2024
80d729c
fix path
aditi-khare-mongoDB Jun 10, 2024
9ca0176
added docker
aditi-khare-mongoDB Jun 18, 2024
a07c524
Merge branch 'main' into NODE-6161/sign-releases
aditi-khare-mongoDB Jun 18, 2024
11c2861
remove msc comment
aditi-khare-mongoDB Jun 18, 2024
e44fc79
remove unnecesary bash
aditi-khare-mongoDB Jun 18, 2024
3964184
typo
aditi-khare-mongoDB Jun 18, 2024
893eb52
typo another one
aditi-khare-mongoDB Jun 18, 2024
87288ec
copy over prebuild file?
aditi-khare-mongoDB Jun 18, 2024
b0bfdfe
move location?
aditi-khare-mongoDB Jun 18, 2024
8b8e8bb
add token
aditi-khare-mongoDB Jun 18, 2024
e2bd188
fixed script?
aditi-khare-mongoDB Jun 18, 2024
1756fb0
not glibc anymore
aditi-khare-mongoDB Jun 18, 2024
a2581b2
directly copy over durrans changes from mongodb-client-encryption
aditi-khare-mongoDB Jun 20, 2024
3d393b0
fix
aditi-khare-mongoDB Jun 20, 2024
b24e792
fix dockerfile
aditi-khare-mongoDB Jun 20, 2024
738d419
requested changes
aditi-khare-mongoDB Jun 20, 2024
c2802b9
fix typo
aditi-khare-mongoDB Jun 20, 2024
0e146d0
fix typo 2
aditi-khare-mongoDB Jun 20, 2024
8047bf8
ready me updates
aditi-khare-mongoDB Jun 20, 2024
221c60d
back to aptitude
aditi-khare-mongoDB Jun 20, 2024
6c820aa
remove install latest
aditi-khare-mongoDB Jun 20, 2024
5e717a8
update prebuild
aditi-khare-mongoDB Jun 20, 2024
6add6d9
add override
aditi-khare-mongoDB Jun 20, 2024
aeb43fc
reinstall deps
aditi-khare-mongoDB Jun 20, 2024
6d4c6e6
fix dep
aditi-khare-mongoDB Jun 20, 2024
66ca5c3
add comma
aditi-khare-mongoDB Jun 20, 2024
09d321f
fix apt
aditi-khare-mongoDB Jun 20, 2024
21d67be
add in new scripts
aditi-khare-mongoDB Jun 20, 2024
0bb729c
revert line
aditi-khare-mongoDB Jun 20, 2024
266fddc
skip incompatible tests on mac
aditi-khare-mongoDB Jun 21, 2024
2068b6f
remove testing support
aditi-khare-mongoDB Jun 21, 2024
677976b
remove testing support 2
aditi-khare-mongoDB Jun 21, 2024
02c941b
add prebuild
aditi-khare-mongoDB Jun 21, 2024
0d2811a
test run
aditi-khare-mongoDB Jun 21, 2024
b552e92
test run fix
aditi-khare-mongoDB Jun 21, 2024
5ad3d75
test run fix 2
aditi-khare-mongoDB Jun 21, 2024
41f44ff
fix?
aditi-khare-mongoDB Jun 21, 2024
f7e3481
maybe
aditi-khare-mongoDB Jun 21, 2024
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
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ runs:
registry-url: 'https://registry.npmjs.org'
- run: npm install -g npm@latest
shell: bash
- run: npm clean-install
- run: npm clean-install --ignore-scripts
shell: bash
71 changes: 71 additions & 0 deletions .github/actions/sign_and_upload_package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Sign and Upload Package
description: 'Signs native modules with garasign'

inputs:
aws_role_arn:
description: 'AWS role input for drivers-github-tools/gpg-sign@v2'
required: true
aws_region_name:
description: 'AWS region name input for drivers-github-tools/gpg-sign@v2'
required: true
aws_secret_id:
description: 'AWS secret id input for drivers-github-tools/gpg-sign@v2'
required: true
npm_package_name:
description: 'The name for the npm package this repository represents'
required: true

runs:
using: composite
steps:
- uses: actions/download-artifact@v4

- name: Make signatures directory
shell: bash
run: mkdir artifacts

- name: Set up drivers-github-tools
uses: mongodb-labs/drivers-github-tools/setup@v2
with:
aws_region_name: ${{ inputs.aws_region_name }}
aws_role_arn: ${{ inputs.aws_role_arn }}
aws_secret_id: ${{ inputs.aws_secret_id }}

- name: Create detached signature
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
with:
filenames: 'build-*'
env:
RELEASE_ASSETS: artifacts/

- name: Copy the tarballs to the artifacts directory
shell: bash
run: for filename in build-*; do cp ${filename} artifacts/; done

- run: npm pack
shell: bash

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

- name: Create detached signature for module
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
with:
filenames: ${{ steps.get_vars.outputs.package_file }}
env:
RELEASE_ASSETS: artifacts/

- name: Display structure of downloaded files
shell: bash
run: ls -la artifacts/

- name: "Upload release artifacts"
run: gh release upload v${{ steps.get_vars.outputs.package_version }} artifacts/*.*
shell: bash
env:
GH_TOKEN: ${{ github.token }}
12 changes: 12 additions & 0 deletions .github/docker/Dockerfile.glibc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG NODE_BUILD_IMAGE=node:16.20.1-bullseye
FROM $NODE_BUILD_IMAGE AS build

WORKDIR /kerberos
COPY . .

RUN npm clean-install --ignore-scripts
RUN npm run prebuild

FROM scratch

COPY --from=build /kerberos/prebuilds/ /
97 changes: 97 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: {}

name: Build and Test

permissions:
contents: write
pull-requests: write
id-token: write

jobs:
host_builds:
strategy:
matrix:
os: [macos-latest, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

aditi-khare-mongoDB marked this conversation as resolved.
Show resolved Hide resolved
- name: Build ${{ matrix.os }} Prebuild
run: |
npm clean-install --ignore-scripts
npm run prebuild

- id: upload
name: Upload prebuild
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.os }}
path: prebuilds/
if-no-files-found: 'error'
retention-days: 1
compression-level: 0

container_builds:
outputs:
artifact_id: ${{ steps.upload.outputs.artifact-id }}
runs-on: ubuntu-latest
strategy:
matrix:
linux_arch: [s390x, arm64, amd64]
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run Buildx
run: |
docker buildx create --name builder --bootstrap --use
docker buildx build --platform linux/${{ matrix.linux_arch }} --output type=local,dest=./prebuilds,platform-split=false -f ./.github/docker/Dockerfile.glibc .

- id: upload
name: Upload prebuild
uses: actions/upload-artifact@v4
with:
name: build-linux-${{ matrix.linux_arch }}
path: prebuilds/
if-no-files-found: 'error'
retention-days: 1
compression-level: 0

release_please:
needs: [host_builds, container_builds]
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- id: release
uses: googleapis/release-please-action@v4

sign_and_upload:
# needs: [release_please]
# if: ${{ needs.release_please.outputs.release_created }}
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
- name: actions/setup
uses: ./.github/actions/setup
- name: actions/sign_and_upload_package
uses: ./.github/actions/sign_and_upload_package
with:
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
aws_region_name: 'us-east-1'
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
npm_package_name: 'kerberos'
# - run: npm publish --provenance
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
103 changes: 0 additions & 103 deletions .github/workflows/release.yml

This file was deleted.

43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,49 @@ Now you can install `kerberos` with the following:
npm install kerberos
```

#### Prebuild Platforms

Below are the platforms that are available as prebuilds on each github release.
`prebuild-install` downloads these automatically depending on the platform you are running npm install on.

- Linux GLIBC 2.23 or later
- s390x
- arm64
- x64
- MacOS universal binary
- x64
- arm64
- Windows
- x64

### Release Integrity

Releases are created automatically and signed using the [Node team's GPG key](https://pgp.mongodb.com/node-driver.asc). This applies to the git tag as well as all release packages provided as part of a GitHub release. To verify the provided packages, download the key and import it using gpg:

```
gpg --import node-driver.asc
```

The GitHub release contains a detached signature file for the NPM package (named
`kerberos-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 kerberos-X.Y.Z.tgz.sig kerberos-X.Y.Z.tgz
```

>[!Note]
No verification is done when using npm to install the package. To ensure release integrity when using npm, download the tarball manually from the GitHub release, verify the signature, then install the package from the downloaded tarball using npm install mongodb-X.Y.Z.tgz.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
No verification is done when using npm to install the package. To ensure release integrity when using npm, download the tarball manually from the GitHub release, verify the signature, then install the package from the downloaded tarball using npm install mongodb-X.Y.Z.tgz.
No verification is done when using npm to install the package. To ensure release integrity when using npm, download the tarball manually from the GitHub release, verify the signature, then install the package from the downloaded tarball using npm install kerberos-X.Y.Z.tgz.


To verify the native `.node` packages, follow the same steps as above.

### Testing

Run the test suite using:
Expand Down
10 changes: 9 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.12'
'MACOSX_DEPLOYMENT_TARGET': '10.12',
"OTHER_CFLAGS": [
"-arch x86_64",
"-arch arm64"
],
"OTHER_LDFLAGS": [
"-arch x86_64",
"-arch arm64"
]
},
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
Expand Down
Loading
Loading