@@ -13,57 +13,55 @@ interface Defaults {
13
13
priorCliVersion : string ;
14
14
}
15
15
16
- const CODEQL_BUNDLE_PREFIX = 'codeql-bundle-' ;
17
-
18
16
function getCodeQLCliVersionForRelease ( release ) : string {
19
17
// We do not currently tag CodeQL bundles based on the CLI version they contain.
20
18
// Instead, we use a marker file `cli-version-<version>.txt` to record the CLI version.
21
19
// This marker file is uploaded as a release asset for all new CodeQL bundles.
22
20
const cliVersionsFromMarkerFiles = release . assets
23
- . map ( ( asset ) => asset . name . match ( / c l i - v e r s i o n - ( .* ) \. t x t / ) ?. [ 1 ] )
24
- . filter ( ( v ) => v )
25
- . map ( ( v ) => v as string ) ;
21
+ . map ( ( asset ) => asset . name . match ( / c l i - v e r s i o n - ( .* ) \. t x t / ) ?. [ 1 ] )
22
+ . filter ( ( v ) => v )
23
+ . map ( ( v ) => v as string ) ;
26
24
if ( cliVersionsFromMarkerFiles . length > 1 ) {
27
25
throw new Error (
28
26
`Release ${ release . tag_name } has multiple CLI version marker files.`
29
- ) ;
30
- } else if ( cliVersionsFromMarkerFiles . length === 0 ) {
31
- throw new Error (
32
- `Failed to find the CodeQL CLI version for release ${ release . tag_name } .`
33
- ) ;
34
- }
35
- return cliVersionsFromMarkerFiles [ 0 ] ;
36
- }
27
+ ) ;
28
+ } else if ( cliVersionsFromMarkerFiles . length === 0 ) {
29
+ throw new Error (
30
+ `Failed to find the CodeQL CLI version for release ${ release . tag_name } .`
31
+ ) ;
32
+ }
33
+ return cliVersionsFromMarkerFiles [ 0 ] ;
34
+ }
37
35
38
- async function getBundleInfoFromRelease ( release ) : Promise < BundleInfo > {
39
- return {
40
- bundleVersion : release . tag_name . substring ( CODEQL_BUNDLE_PREFIX . length ) ,
41
- cliVersion : getCodeQLCliVersionForRelease ( release )
42
- } ;
43
- }
36
+ async function getBundleInfoFromRelease ( release ) : Promise < BundleInfo > {
37
+ return {
38
+ bundleVersion : release . tag_name ,
39
+ cliVersion : getCodeQLCliVersionForRelease ( release )
40
+ } ;
41
+ }
44
42
45
- async function getNewDefaults ( currentDefaults : Defaults ) : Promise < Defaults > {
46
- const release = github . context . payload . release ;
47
- console . log ( 'Updating default bundle as a result of the following release: ' +
48
- `${ JSON . stringify ( release ) } .` )
43
+ async function getNewDefaults ( currentDefaults : Defaults ) : Promise < Defaults > {
44
+ const release = github . context . payload . release ;
45
+ console . log ( 'Updating default bundle as a result of the following release: ' +
46
+ `${ JSON . stringify ( release ) } .` )
49
47
50
- const bundleInfo = await getBundleInfoFromRelease ( release ) ;
51
- return {
52
- bundleVersion : bundleInfo . bundleVersion ,
53
- cliVersion : bundleInfo . cliVersion ,
54
- priorBundleVersion : currentDefaults . bundleVersion ,
55
- priorCliVersion : currentDefaults . cliVersion
56
- } ;
57
- }
48
+ const bundleInfo = await getBundleInfoFromRelease ( release ) ;
49
+ return {
50
+ bundleVersion : bundleInfo . bundleVersion ,
51
+ cliVersion : bundleInfo . cliVersion ,
52
+ priorBundleVersion : currentDefaults . bundleVersion ,
53
+ priorCliVersion : currentDefaults . cliVersion
54
+ } ;
55
+ }
58
56
59
- async function main ( ) {
60
- const previousDefaults : Defaults = JSON . parse ( fs . readFileSync ( '../../../src/defaults.json' , 'utf8' ) ) ;
61
- const newDefaults = await getNewDefaults ( previousDefaults ) ;
62
- // Update the source file in the repository. Calling workflows should subsequently rebuild
63
- // the Action to update `lib/defaults.json`.
64
- fs . writeFileSync ( '../../../src/defaults.json' , JSON . stringify ( newDefaults , null , 2 ) + "\n" ) ;
65
- }
57
+ async function main ( ) {
58
+ const previousDefaults : Defaults = JSON . parse ( fs . readFileSync ( '../../../src/defaults.json' , 'utf8' ) ) ;
59
+ const newDefaults = await getNewDefaults ( previousDefaults ) ;
60
+ // Update the source file in the repository. Calling workflows should subsequently rebuild
61
+ // the Action to update `lib/defaults.json`.
62
+ fs . writeFileSync ( '../../../src/defaults.json' , JSON . stringify ( newDefaults , null , 2 ) + "\n" ) ;
63
+ }
66
64
67
- // Ideally, we'd await main() here, but that doesn't work well with `ts-node`.
68
- // So instead we rely on the fact that Node won't exit until the event loop is empty.
69
- main ( ) ;
65
+ // Ideally, we'd await main() here, but that doesn't work well with `ts-node`.
66
+ // So instead we rely on the fact that Node won't exit until the event loop is empty.
67
+ main ( ) ;
0 commit comments