mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
[windows] Pin PostgreSQL and Update LLVM (#10014)
* [windows] Pin PostgreSQL version * Fix if statement * Fix PostgreSQL pester test * Update LLVM to 18*
This commit is contained in:
committed by
GitHub
parent
7271f004d4
commit
870d08d9cb
@@ -11,44 +11,52 @@ $pgPwd = "root"
|
||||
[Environment]::SetEnvironmentVariable("PGUSER", $pgUser, "Machine")
|
||||
[Environment]::SetEnvironmentVariable("PGPASSWORD", $pgPwd, "Machine")
|
||||
|
||||
# Define latest available version to install based on version specified in the toolset
|
||||
$toolsetVersion = (Get-ToolsetContent).postgresql.version
|
||||
$getPostgreReleases = Invoke-WebRequest -Uri "https://git.postgresql.org/gitweb/?p=postgresql.git;a=tags" -UseBasicParsing
|
||||
# Getting all links matched to the pattern (e.g.a=log;h=refs/tags/REL_14)
|
||||
$targetReleases = $getPostgreReleases.Links.href | Where-Object { $_ -match "a=log;h=refs/tags/REL_$toolsetVersion" }
|
||||
[Int32] $outNumber = $null
|
||||
$minorVersions = @()
|
||||
foreach ($release in $targetReleases) {
|
||||
$version = $release.split('/')[-1]
|
||||
# Checking if the latest symbol of the release version is actually a number. If yes, add to $minorVersions array
|
||||
if ([Int32]::TryParse($($version.Split('_')[-1]), [ref] $outNumber)) {
|
||||
$minorVersions += $outNumber
|
||||
if ($null -ne ($toolsetVersion | Select-String -Pattern '\d+\.\d+\.\d+')) {
|
||||
$majorVersion = ([version]$toolsetVersion).Major
|
||||
$minorVersion = ([version]$toolsetVersion).Minor
|
||||
$patchVersion = ([version]$toolsetVersion).Build
|
||||
$installerUrl = "https://get.enterprisedb.com/postgresql/postgresql-$majorVersion.$minorVersion-$patchVersion-windows-x64.exe"
|
||||
} else {
|
||||
# Define latest available version to install based on version specified in the toolset
|
||||
$getPostgreReleases = Invoke-WebRequest -Uri "https://git.postgresql.org/gitweb/?p=postgresql.git;a=tags" -UseBasicParsing
|
||||
# Getting all links matched to the pattern (e.g.a=log;h=refs/tags/REL_14)
|
||||
$targetReleases = $getPostgreReleases.Links.href | Where-Object { $_ -match "a=log;h=refs/tags/REL_$toolsetVersion" }
|
||||
[Int32] $outNumber = $null
|
||||
$minorVersions = @()
|
||||
foreach ($release in $targetReleases) {
|
||||
$version = $release.split('/')[-1]
|
||||
# Checking if the latest symbol of the release version is actually a number. If yes, add to $minorVersions array
|
||||
if ([Int32]::TryParse($($version.Split('_')[-1]), [ref] $outNumber)) {
|
||||
$minorVersions += $outNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
# Sorting and getting the last one
|
||||
$targetMinorVersions = ($minorVersions | Sort-Object)[-1]
|
||||
# Sorting and getting the last one
|
||||
$targetMinorVersions = ($minorVersions | Sort-Object)[-1]
|
||||
|
||||
# Install latest PostgreSQL
|
||||
# In order to get rid of error messages (we know we will have them), force ErrorAction to SilentlyContinue
|
||||
$errorActionOldValue = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
# Starting from number 9 and going down, check if the installer is available. If yes, break the loop.
|
||||
# If an installer with $targetMinorVersions is not to be found, the $targetMinorVersions will be decreased by 1
|
||||
$increment = 9
|
||||
do {
|
||||
$url = "https://get.enterprisedb.com/postgresql/postgresql-$toolsetVersion.$targetMinorVersions-$increment-windows-x64.exe"
|
||||
$checkAccess = [System.Net.WebRequest]::Create($url)
|
||||
$response = $null
|
||||
$response = $checkAccess.GetResponse()
|
||||
if ($response) {
|
||||
$installerUrl = $response.ResponseUri.OriginalString
|
||||
} elseif (!$response -and ($increment -eq 0)) {
|
||||
$increment = 9
|
||||
$targetMinorVersions--
|
||||
} else {
|
||||
$increment--
|
||||
}
|
||||
} while (!$response)
|
||||
# In order to get rid of error messages (we know we will have them), force ErrorAction to SilentlyContinue
|
||||
$errorActionOldValue = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
|
||||
# Install latest PostgreSQL
|
||||
# Starting from number 9 and going down, check if the installer is available. If yes, break the loop.
|
||||
# If an installer with $targetMinorVersions is not to be found, the $targetMinorVersions will be decreased by 1
|
||||
$increment = 9
|
||||
do {
|
||||
$url = "https://get.enterprisedb.com/postgresql/postgresql-$toolsetVersion.$targetMinorVersions-$increment-windows-x64.exe"
|
||||
$checkAccess = [System.Net.WebRequest]::Create($url)
|
||||
$response = $null
|
||||
$response = $checkAccess.GetResponse()
|
||||
if ($response) {
|
||||
$installerUrl = $response.ResponseUri.OriginalString
|
||||
} elseif (!$response -and ($increment -eq 0)) {
|
||||
$increment = 9
|
||||
$targetMinorVersions--
|
||||
} else {
|
||||
$increment--
|
||||
}
|
||||
} while (!$response)
|
||||
}
|
||||
|
||||
# Return the previous value of ErrorAction and invoke Install-Binary function
|
||||
$ErrorActionPreference = $errorActionOldValue
|
||||
|
||||
Reference in New Issue
Block a user