mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-23 09:57:17 +08:00
[Windows] CodeQL: Simplify the toolcache version number for bundles tagged using semver (#7718)
This commit is contained in:
@@ -3,16 +3,42 @@
|
|||||||
## Desc: Install the CodeQL CLI Bundle to the toolcache.
|
## Desc: Install the CodeQL CLI Bundle to the toolcache.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Retrieve the name of the CodeQL bundle preferred by the Action (in the format codeql-bundle-YYYYMMDD).
|
# Retrieve the CLI versions and bundle tags of the latest two CodeQL bundles.
|
||||||
$Defaults = (Invoke-RestMethod "https://raw.githubusercontent.com/github/codeql-action/v2/src/defaults.json")
|
$Defaults = (Invoke-RestMethod "https://raw.githubusercontent.com/github/codeql-action/v2/src/defaults.json")
|
||||||
$CodeQLTagName = $Defaults.bundleVersion
|
$CodeQLTagName = $Defaults.bundleVersion
|
||||||
$CodeQLCliVersion = $Defaults.cliVersion
|
$CodeQLCliVersion = $Defaults.cliVersion
|
||||||
$PriorCodeQLTagName = $Defaults.priorBundleVersion
|
$PriorCodeQLTagName = $Defaults.priorBundleVersion
|
||||||
$PriorCodeQLCliVersion = $Defaults.priorCliVersion
|
$PriorCodeQLCliVersion = $Defaults.priorCliVersion
|
||||||
|
|
||||||
# Convert the tag names to bundles with a version number (x.y.z-YYYYMMDD).
|
# Compute the toolcache version number for each bundle. This is either `x.y.z` or `x.y.z-YYYYMMDD`.
|
||||||
$CodeQLBundleVersion = $CodeQLCliVersion + "-" + $CodeQLTagName.split("-")[-1]
|
if ($CodeQLTagName.split("-")[-1].StartsWith("v")) {
|
||||||
$PriorCodeQLBundleVersion = $PriorCodeQLCliVersion + "-" + $PriorCodeQLTagName.split("-")[-1]
|
# Tag name of the format `codeql-bundle-vx.y.z`, where x.y.z is the CLI version.
|
||||||
|
# We don't need to include the tag name in the toolcache version number because it's derivable
|
||||||
|
# from the CLI version.
|
||||||
|
$CodeQLBundleVersion = $CodeQLCliVersion
|
||||||
|
} elseif ($CodeQLTagName.split("-")[-1] -match "^\d+$") {
|
||||||
|
# Tag name of the format `codeql-bundle-YYYYMMDD`.
|
||||||
|
# We need to include the tag name in the toolcache version number because it can't be derived
|
||||||
|
# from the CLI version.
|
||||||
|
$CodeQLBundleVersion = $CodeQLCliVersion + "-" + $CodeQLTagName.split("-")[-1]
|
||||||
|
} else {
|
||||||
|
Write-Error "Unrecognised current CodeQL bundle tag name: $CodeQLTagName. Could not compute toolcache version number."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
if ($PriorCodeQLTagName.split("-")[-1].StartsWith("v")) {
|
||||||
|
# Tag name of the format `codeql-bundle-vx.y.z`, where x.y.z is the CLI version.
|
||||||
|
# We don't need to include the tag name in the toolcache version number because it's derivable
|
||||||
|
# from the CLI version.
|
||||||
|
$PriorCodeQLBundleVersion = $PriorCodeQLCliVersion
|
||||||
|
} elseif ($PriorCodeQLTagName.split("-")[-1] -match "^\d+$") {
|
||||||
|
# Tag name of the format `codeql-bundle-YYYYMMDD`.
|
||||||
|
# We need to include the tag name in the toolcache version number because it can't be derived
|
||||||
|
# from the CLI version.
|
||||||
|
$PriorCodeQLBundleVersion = $PriorCodeQLCliVersion + "-" + $PriorCodeQLTagName.split("-")[-1]
|
||||||
|
} else {
|
||||||
|
Write-Error "Unrecognised prior CodeQL bundle tag name: $PriorCodeQLTagName. Could not compute toolcache version number."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
$Bundles = @(
|
$Bundles = @(
|
||||||
[PSCustomObject]@{
|
[PSCustomObject]@{
|
||||||
|
|||||||
Reference in New Issue
Block a user