@@ -23,6 +23,7 @@ program
23
23
. command ( 'beta' )
24
24
. description ( 'Starts a new beta' )
25
25
. option ( '--merge-branch <mergeBranch>' , 'branch to merge' , 'main' )
26
+ . option ( '--submitter <name>' , 'github username of the releaser' , '' )
26
27
. option (
27
28
'--next-ga [nextGa]' ,
28
29
'next ga version, default to the next GA version in Jira'
@@ -32,6 +33,10 @@ program
32
33
if ( ! options . mergeBranch ) {
33
34
throw new Error ( 'mergeBranch is required' ) ;
34
35
}
36
+ if ( ! options . submitter ) {
37
+ throw new Error ( 'submitter is required' ) ;
38
+ }
39
+ const publisher = getReleasePublisher ( options . submitter ) ;
35
40
36
41
const nextGa = options . nextGa || ( await getNextGaVersionInJira ( ) ) ;
37
42
@@ -62,13 +67,14 @@ program
62
67
console . info ( `Promoting ${ currentCompassPackageVersion } to ${ nextBeta } ` ) ;
63
68
64
69
await syncWithBranch ( options . mergeBranch ) ;
65
- await bumpAndPush ( nextBeta , BETA_RELEASE_BRANCH ) ;
70
+ await bumpAndPush ( nextBeta , BETA_RELEASE_BRANCH , publisher ) ;
66
71
} ) ;
67
72
68
73
program
69
74
. command ( 'ga' )
70
75
. description ( 'Starts a new GA' )
71
76
. option ( '--release-ticket <releaseTicket>' )
77
+ . option ( '--submitter <name>' , 'github username of the releaser' , '' )
72
78
. option (
73
79
'--merge-branch <mergeBranch>' ,
74
80
'branch to merge' ,
@@ -83,6 +89,10 @@ program
83
89
if ( ! options . mergeBranch ) {
84
90
throw new Error ( 'mergeBranch is required' ) ;
85
91
}
92
+ if ( ! options . submitter ) {
93
+ throw new Error ( 'submitter is required' ) ;
94
+ }
95
+ const publisher = getReleasePublisher ( options . submitter ) ;
86
96
87
97
const nextGa = await getReleaseVersionFromTicket ( options . releaseTicket ) ;
88
98
@@ -104,7 +114,7 @@ program
104
114
}
105
115
106
116
console . info ( `Promoting ${ currentCompassPackageVersion } to ${ nextGa } ` ) ;
107
- await bumpAndPush ( nextGa , GA_RELEASE_BRANCH ) ;
117
+ await bumpAndPush ( nextGa , GA_RELEASE_BRANCH , publisher ) ;
108
118
} ) ;
109
119
110
120
program . parseAsync ( ) ;
@@ -159,8 +169,37 @@ async function gitCheckout(branchName) {
159
169
} ) ;
160
170
}
161
171
162
- async function bumpAndPush ( nextVersion , releaseBranch ) {
163
- await execFile ( 'npm' , [ 'version' , nextVersion ] , { cwd : compassPackagePath } ) ;
172
+ async function getReleasePublisher ( submitter ) {
173
+ const publisherData = (
174
+ await execFile (
175
+ 'git' ,
176
+ [ 'check-mailmap' , `<${ submitter } @users.noreply.github.com>` ] ,
177
+ {
178
+ cwd : monorepoRoot ,
179
+ encoding : 'utf8' ,
180
+ }
181
+ )
182
+ ) . stdout . trim ( ) ;
183
+
184
+ if ( ! publisherData . match ( / ^ [ ^ < ] + < [ ^ @ > ] + @ m o n g o d b .c o m > / ) ) {
185
+ throw new Error (
186
+ `Could not translate username ${ submitter } to recognized authorized email (${ publisherData } )`
187
+ ) ;
188
+ }
189
+ return publisherData ;
190
+ }
191
+
192
+ async function bumpAndPush ( nextVersion , releaseBranch , publisher ) {
193
+ await execFile ( 'npm' , [ 'version' , '--no-git-tag-version' , nextVersion ] , {
194
+ cwd : compassPackagePath ,
195
+ } ) ;
196
+ await fs . writeFile (
197
+ compassPackageJsonPath ,
198
+ JSON . stringify ( {
199
+ ...JSON . parse ( await fs . readFile ( compassPackageJsonPath , 'utf8' ) ) ,
200
+ releasePublisher : publisher ,
201
+ } )
202
+ ) ;
164
203
await execFile ( 'git' , [ 'add' , compassPackageJsonPath , `package-lock.json` ] , {
165
204
cwd : monorepoRoot ,
166
205
} ) ;
@@ -174,6 +213,26 @@ async function bumpAndPush(nextVersion, releaseBranch) {
174
213
cwd : monorepoRoot ,
175
214
} ) ;
176
215
await execFile ( 'git' , [ 'push' , '--tags' ] , { cwd : monorepoRoot } ) ;
216
+
217
+ const currentBranch = (
218
+ await execFile ( 'git' , [ 'branch' , '--show-current' ] , {
219
+ cwd : monorepoRoot ,
220
+ encoding : 'utf8' ,
221
+ } )
222
+ ) . stdout . trim ( ) ;
223
+ await execFile (
224
+ 'gh' ,
225
+ [
226
+ 'workflow' ,
227
+ 'run' ,
228
+ 'codeql.yml' ,
229
+ '-R' ,
230
+ 'mongodb-js/compass' ,
231
+ '-r' ,
232
+ currentBranch ,
233
+ ] ,
234
+ { cwd : monorepoRoot }
235
+ ) ;
177
236
}
178
237
179
238
// NOTE: if there are more "unreleased" versions it will
0 commit comments