Skip to content

Commit

Permalink
prettier changes
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Jun 26, 2024
1 parent 508b0f1 commit 2f3357e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 137 deletions.
48 changes: 30 additions & 18 deletions node/generate_release.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
const { readFileSync } = require('fs');
const { join } = require('path');
const { readFileSync } = require("fs");
const { join } = require("path");

const args = process.argv.slice(2);
if (args.length != 3) {
console.error(`usage: generate_release.js <package> <branch> <npm tag>`);
process.exit(1);
if (!(args.length === 3 || args.length === 4)) {
console.error(
`usage: generate_release.js <package> <branch> <npm tag> <optional silk asset group>`,
);
process.exit(1);
}

const [package, branch, tag] = args;
const [package, branch, tag, assetGroup] = args;

const isNative = package === 'kerberos' || package === 'mongodb-client-encryption';
const template = readFileSync(join(__dirname, isNative ? './native_release_template.yml' : './release_template.yml'), 'utf-8');
const isNative =
package === "kerberos" || package === "mongodb-client-encryption";
const template = readFileSync(
join(__dirname, "./release_template.yml"),
"utf-8",
);

const EVERGREEN_PROJECTS = {
'mongodb': 'mongo-node-driver-next',
'bson': 'js-bson'
mongodb: "mongo-node-driver-next",
bson: "js-bson",
};

const generated = template.replaceAll('RELEASE_BRANCH', branch)
.replaceAll('RELEASE_PACKAGE', package)
.replaceAll('RELEASE_TAG', tag)
.replaceAll('EVERGREEN_PROJECT', EVERGREEN_PROJECTS[package] ?? '');
const generated = template
.replaceAll("RELEASE_BRANCH", branch)
.replaceAll("RELEASE_PACKAGE", package)
.replaceAll("RELEASE_TAG", tag)
.replaceAll("EVERGREEN_PROJECT", EVERGREEN_PROJECTS[package] ?? "")
.replaceAll("IGNORE_INSTALL_SCRIPTS", isNative)
.replaceAll("SILK_ASSET_GROUP", assetGroup ?? "''");

const project = EVERGREEN_PROJECTS[package];
if (!project) {
const final = generated.split('\n').filter(line => !line.includes("evergreen")).join('\n');
process.stdout.write(final);
process.exit();
const final = generated
.split("\n")
.filter((line) => !line.includes("evergreen"))
.join("\n");
process.stdout.write(final);
process.exit();
}

process.stdout.write(generated);
process.stdout.write(generated);
1 change: 0 additions & 1 deletion node/get_version_info/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Publish Release Asset to S3
description: "Publish Asset to S3"
inputs:
Expand Down
96 changes: 0 additions & 96 deletions node/native_release_template.yml

This file was deleted.

22 changes: 19 additions & 3 deletions node/release_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ jobs:
with:
target-branch: RELEASE_BRANCH

ssdlc:
build:
needs: [release_please]
name: "Perform any build or bundling steps, as necessary."
uses: ./.github/workflows/build.yml

ssdlc:
needs: [release_please, build]
permissions:
# required for all workflows
security-events: write
Expand All @@ -35,6 +40,8 @@ jobs:

- name: Install Node and dependencies
uses: baileympearson/drivers-github-tools/node/setup@add-signing-env-action-for-node
with:
ignore_install_scripts: IGNORE_INSTALL_SCRIPTS

- name: Load version and package info
uses: baileympearson/drivers-github-tools/node/get_version_info@add-signing-env-action-for-node
Expand All @@ -52,8 +59,17 @@ jobs:

- name: Copy sbom file to release assets
shell: bash
if: ${{ SILK_ASSET_GROUP == '' }}
run: cp sbom.json ${{ env.S3_ASSETS }}/sbom.json

# only used for mongodb-client-encryption
- name: Augment SBOM and copy to release assets
if: ${{ SILK_ASSET_GROUP != '' }}
uses: mongodb-labs/drivers-github-tools/sbom@v2
with:
silk_asset_group: ${{ SILK_ASSET_GROUP }}
sbom_file_name: sbom.json

- name: Generate authorized pub report
uses: mongodb-labs/drivers-github-tools/full-report@v2
with:
Expand All @@ -62,7 +78,7 @@ jobs:
sarif_report_target_ref: RELEASE_BRANCH
third_party_dependency_tool: n/a
dist_filenames: artifacts/*
token: ${{ github.token }}
token: ${{ github.token }}
sbom_file_name: sbom.json
evergreen_project: EVERGREEN_PROJECT
evergreen_commit: ${{ env.commit }}
Expand All @@ -74,7 +90,7 @@ jobs:
dry_run: ${{ needs.release_please.outputs.release_created == '' }}

publish:
needs: [release_please, ssdlc]
needs: [release_please, ssdlc, build]
environment: release
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 7 additions & 7 deletions node/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Setup
description: 'Installs node, driver dependencies, and builds source'
inputs:
description: "Installs node, driver dependencies, and builds source"
inputs:
ignore_install_scripts:
description: Should we ignore postinstall scripts?
default: 'false'
default: "false"

runs:
using: composite
steps:
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
node-version: "lts/*"
cache: "npm"
registry-url: "https://registry.npmjs.org"
- run: npm install -g npm@latest
shell: bash
- run: npm clean-install
if: ${{ inputs.ignore_install_scripts == 'false' }}
shell: bash
- run: npm clean-install --ignore-scripts
if: ${{ inputs.ignore_install_scripts == 'true' }}
shell: bash
shell: bash
24 changes: 12 additions & 12 deletions node/sign_node_package/action.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Compress, Sign and Upload to GH Release
description: 'Compresses package and signs with garasign and uploads to GH release'
description: "Compresses package and signs with garasign and uploads to GH release"

inputs:
inputs:
aws_role_arn:
description: 'AWS role input for drivers-github-tools/gpg-sign@v2'
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'
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'
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'
description: "The name for the npm package this repository represents"
required: true
dry_run:
description: 'Should we upload files to the release?'
description: "Should we upload files to the release?"
required: false
default: 'true'
default: "true"
artifact_directory:
description: The directory in which to output signatures.
default: artifacts
Expand Down Expand Up @@ -45,7 +45,7 @@ runs:

- name: Set up drivers-github-tools
uses: mongodb-labs/drivers-github-tools/setup@v2
with:
with:
aws_region_name: ${{ inputs.aws_region_name }}
aws_role_arn: ${{ inputs.aws_role_arn }}
aws_secret_id: ${{ inputs.aws_secret_id }}
Expand All @@ -70,9 +70,9 @@ runs:
- name: Create detached signature
uses: baileympearson/drivers-github-tools/gpg-sign@add-signing-env-action-for-node
with:
with:
filenames: ${{ env.FILES_TO_SIGN }}
env:
env:
RELEASE_ASSETS: ${{ inputs.artifact_directory }}

- name: Copy the tarballs to the artifacts directory
Expand All @@ -88,4 +88,4 @@ runs:
run: gh release upload v${{ env.package_version }} artifacts/*.*
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}

0 comments on commit 2f3357e

Please sign in to comment.