Fix computation of fallback version
This commit is contained in:
parent
0a9e9db27f
commit
75ae065ae6
3 changed files with 29 additions and 9 deletions
15
lib/setup-codeql.js
generated
15
lib/setup-codeql.js
generated
|
|
@ -211,12 +211,19 @@ async function getCodeQLBundleDownloadURL(tagName, apiDetails, variant, logger)
|
|||
}
|
||||
return `https://github.com/${exports.CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${codeQLBundleName}`;
|
||||
}
|
||||
function getBundleVersionFromTagName(tagName) {
|
||||
const match = tagName.match(/^codeql-bundle-(.*)$/);
|
||||
if (match === null || match.length < 2) {
|
||||
throw new Error(`Malformed bundle tag name: ${tagName}. Bundle version could not be inferred`);
|
||||
}
|
||||
return match[1];
|
||||
}
|
||||
function getBundleVersionFromUrl(url) {
|
||||
const match = url.match(/\/codeql-bundle-(.*)\//);
|
||||
const match = url.match(/\/(codeql-bundle-.*)\//);
|
||||
if (match === null || match.length < 2) {
|
||||
throw new Error(`Malformed tools url: ${url}. Bundle version could not be inferred`);
|
||||
}
|
||||
return match[1];
|
||||
return getBundleVersionFromTagName(match[1]);
|
||||
}
|
||||
exports.getBundleVersionFromUrl = getBundleVersionFromUrl;
|
||||
function convertToSemVer(version, logger) {
|
||||
|
|
@ -349,14 +356,14 @@ async function getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, a
|
|||
}
|
||||
}
|
||||
if (!codeqlFolder && requestedVersion.cliVersion) {
|
||||
// Fall back to accepting a `0.0.0-<tagName>` version if we didn't find the
|
||||
// Fall back to accepting a `0.0.0-<bundleVersion>` version if we didn't find the
|
||||
// `x.y.z` version. This is to support old versions of the toolcache.
|
||||
//
|
||||
// If we are on Dotcom, we will make an HTTP request to the Releases API here
|
||||
// to find the tag name for the requested version.
|
||||
tagName =
|
||||
tagName || (await getOrFindBundleTagName(requestedVersion, logger));
|
||||
const fallbackVersion = convertToSemVer(tagName, logger);
|
||||
const fallbackVersion = convertToSemVer(getBundleVersionFromTagName(tagName), logger);
|
||||
logger.debug(`Computed a fallback toolcache version number of ${fallbackVersion} for CodeQL tools version ` +
|
||||
`${requestedVersion.cliVersion}.`);
|
||||
codeqlFolder = toolcache.find("CodeQL", fallbackVersion);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue