Skip to content

Commit

Permalink
Add a comment about lib/defaults.json
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Apr 3, 2023
1 parent f6091a0 commit 98173be
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/actions/update-bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ function getCodeQLCliVersionForRelease(release): string {
}
return cliVersionsFromMarkerFiles[0];
}

async function getBundleInfoFromRelease(release): Promise<BundleInfo> {
return {
bundleVersion: release.tag_name.substring(CODEQL_BUNDLE_PREFIX.length),
cliVersion: getCodeQLCliVersionForRelease(release)
};
}

async function getNewDefaults(currentDefaults: Defaults): Promise<Defaults> {
const release = github.context.payload.release;
console.log('Updating default bundle as a result of the following release: ' +
`${JSON.stringify(release)}.`)

const bundleInfo = await getBundleInfoFromRelease(release);
return {
bundleVersion: bundleInfo.bundleVersion,
Expand All @@ -55,14 +55,15 @@ function getCodeQLCliVersionForRelease(release): string {
priorCliVersion: currentDefaults.cliVersion
};
}

async function main() {
const previousDefaults: Defaults = JSON.parse(fs.readFileSync('../../../src/defaults.json', 'utf8'));
const newDefaults = await getNewDefaults(previousDefaults);
// Update the source file in the repository. Calling workflows should subsequently rebuild
// the Action to update `lib/defaults.json`.
fs.writeFileSync('../../../src/defaults.json', JSON.stringify(newDefaults, null, 2) + "\n");
}

// Ideally, we'd await main() here, but that doesn't work well with `ts-node`.
// So instead we rely on the fact that Node won't exit until the event loop is empty.
main();

0 comments on commit 98173be

Please sign in to comment.