Skip to content

Commit 508b0f1

Browse files
make action shared
1 parent 8d5ff35 commit 508b0f1

File tree

5 files changed

+109
-6
lines changed

5 files changed

+109
-6
lines changed

node/generate_release.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const { join } = require('path');
44
const args = process.argv.slice(2);
55
if (args.length != 3) {
66
console.error(`usage: generate_release.js <package> <branch> <npm tag>`);
7-
process.exitCode = 1;
8-
process.exit();
7+
process.exit(1);
98
}
109

1110
const [package, branch, tag] = args;
1211

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

1515
const EVERGREEN_PROJECTS = {
1616
'mongodb': 'mongo-node-driver-next',

node/native_release_template.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
on:
2+
push:
3+
branches: [RELEASE_BRANCH]
4+
workflow_dispatch: {}
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
id-token: write
10+
11+
name: release-RELEASE_TAG
12+
13+
jobs:
14+
release_please:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
release_created: ${{ steps.release.outputs.release_created }}
18+
steps:
19+
- id: release
20+
uses: googleapis/release-please-action@v4
21+
with:
22+
target-branch: RELEASE_BRANCH
23+
24+
build:
25+
needs: [release_please]
26+
name: "Perform any build or bundling steps, as necessary."
27+
uses: ./.github/workflows/build.yml
28+
29+
ssdlc:
30+
needs: [release_please, build]
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
id-token: write
35+
contents: write
36+
environment: release
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Install Node and dependencies
42+
uses: baileympearson/drivers-github-tools/node/setup@add-signing-env-action-for-node
43+
with:
44+
ignore_install_scripts: true
45+
46+
- name: Load version and package info
47+
uses: baileympearson/drivers-github-tools/node/get_version_info@add-signing-env-action-for-node
48+
with:
49+
npm_package_name: RELEASE_PACKAGE
50+
51+
- name: actions/compress_sign_and_upload
52+
uses: baileympearson/drivers-github-tools/node/sign_node_package@add-signing-env-action-for-node
53+
with:
54+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
55+
aws_region_name: us-east-1
56+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
57+
npm_package_name: RELEASE_PACKAGE
58+
dry_run: ${{ needs.release_please.outputs.release_created == '' }}
59+
60+
- name: Copy sbom file to release assets
61+
shell: bash
62+
run: cp sbom.json ${{ env.S3_ASSETS }}/sbom.json
63+
64+
- name: Generate authorized pub report
65+
uses: mongodb-labs/drivers-github-tools/full-report@v2
66+
with:
67+
release_version: ${{ env.package_version }}
68+
product_name: RELEASE_PACKAGE
69+
sarif_report_target_ref: RELEASE_BRANCH
70+
third_party_dependency_tool: n/a
71+
dist_filenames: artifacts/*
72+
token: ${{ github.token }}
73+
sbom_file_name: sbom.json
74+
evergreen_project: EVERGREEN_PROJECT
75+
evergreen_commit: ${{ env.commit }}
76+
77+
- uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
78+
with:
79+
version: ${{ env.package_version }}
80+
product_name: RELEASE_PACKAGE
81+
dry_run: ${{ needs.release_please.outputs.release_created == '' }}
82+
83+
publish:
84+
needs: [release_please, ssdlc, build]
85+
environment: release
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- name: Install Node and dependencies
91+
uses: baileympearson/drivers-github-tools/node/setup@add-signing-env-action-for-node
92+
93+
- run: npm publish --provenance --tag=RELEASE_TAG
94+
if: ${{ needs.release_please.outputs.release_created }}
95+
env:
96+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

node/release_template.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
npm_package_name: RELEASE_PACKAGE
4343

4444
- name: actions/compress_sign_and_upload
45-
uses: baileympearson/drivers-github-tools/node/sign_js_only_package@add-signing-env-action-for-node
45+
uses: baileympearson/drivers-github-tools/node/sign_node_package@add-signing-env-action-for-node
4646
with:
4747
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
4848
aws_region_name: us-east-1
@@ -61,8 +61,7 @@ jobs:
6161
product_name: RELEASE_PACKAGE
6262
sarif_report_target_ref: RELEASE_BRANCH
6363
third_party_dependency_tool: n/a
64-
# <package> and <package>.sig
65-
dist_filenames: ${{ env.package_file }}*
64+
dist_filenames: artifacts/*
6665
token: ${{ github.token }}
6766
sbom_file_name: sbom.json
6867
evergreen_project: EVERGREEN_PROJECT

node/setup/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Setup
22
description: 'Installs node, driver dependencies, and builds source'
3+
inputs:
4+
ignore_install_scripts:
5+
description: Should we ignore postinstall scripts?
6+
default: 'false'
37

48
runs:
59
using: composite
@@ -12,4 +16,8 @@ runs:
1216
- run: npm install -g npm@latest
1317
shell: bash
1418
- run: npm clean-install
19+
if: ${{ inputs.ignore_install_scripts == 'false' }}
1520
shell: bash
21+
- run: npm clean-install --ignore-scripts
22+
if: ${{ inputs.ignore_install_scripts == 'true' }}
23+
shell: bash

0 commit comments

Comments
 (0)