Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Simplify version parsing and skip windows versions if continue=no
Browse files Browse the repository at this point in the history
  • Loading branch information
harrisonmeister committed Sep 27, 2023
1 parent 8cb72e1 commit 5eaab84
Showing 1 changed file with 42 additions and 31 deletions.
73 changes: 42 additions & 31 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,52 @@ jobs:
name: Compare latest version with container
run: |
$chocoInformationRaw = choco info awscli --limitoutput
$version = ($chocoInformationRaw.Split("|"))[1]
$versionSplit = $version.Split(".")
$versionToCompare = "$($versionSplit[0]).$($versionSplit[1]).$($versionSplit[2])"
$versionOutput = ($chocoInformationRaw.Split("|"))[1]
$workerToolsTags = Invoke-RestMethod "https://registry.hub.docker.com/v2/repositories/octopuslabs/aws-workertools/tags?page_size=50"
$matchingTag = $workerToolsTags.results | Where-Object { $_.name -eq $versionToCompare }
echo "VERSION=$versionToCompare" >> $env:GITHUB_OUTPUT
if ($null -ne $matchingTag)
{
Write-Host "Docker container already has latest version"
[System.Version]$version = $null
$versionParsed = [System.Version]::TryParse($versionOutput, [ref]$version)
if(-not $versionParsed) {
Write-Host "Unable to parse '$versionOutput' as a valid version. Won't continue"
echo "CONTINUE=No" >> $env:GITHUB_OUTPUT
}
else
{
Write-Host "We need to upgrade the container to $versionToCompare"
echo "CONTINUE=Yes" >> $env:GITHUB_OUTPUT
else {
$versionToCompare = "$($version.Major).$($version.Minor).$($version.Build)"
Write-Host "Parsed version as $versionToCompare"
$workerToolsTags = Invoke-RestMethod "https://registry.hub.docker.com/v2/repositories/octopuslabs/aws-workertools/tags?page_size=50"
$matchingTag = $workerToolsTags.results | Where-Object { $_.name -eq $versionToCompare }
echo "VERSION=$versionToCompare" >> $env:GITHUB_OUTPUT
if ($null -ne $matchingTag)
{
Write-Host "Docker container already has latest version"
echo "CONTINUE=No" >> $env:GITHUB_OUTPUT
}
else
{
Write-Host "We need to upgrade the container to $versionToCompare"
Write-Host "Getting OS versions for windows 2022 and 2019"
$win2019_manifest = (docker manifest inspect --verbose "octopuslabs/workertools:latest-windows.2019" | ConvertFrom-Json)
$WIN2019_VERSION = $win2019_manifest.Descriptor.Platform.'os.version'
Write-Host "WIN2019_VERSION: $WIN2019_VERSION"
$win2022_manifest = (docker manifest inspect --verbose "octopuslabs/workertools:latest-windows.2022" | ConvertFrom-Json)
$WIN2022_VERSION = $win2022_manifest.Descriptor.Platform.'os.version'
Write-Host "WIN2022_VERSION: $WIN2022_VERSION"
if([string]::IsNullOrWhiteSpace($WIN2019_VERSION) -or [string]::IsNullOrWhiteSpace($WIN2022_VERSION)) {
throw "Could not establish OS versions for windows 2022 and 2019 needed for docker manifest"
}
echo "WIN2019_VERSION=$WIN2019_VERSION" >> $env:GITHUB_OUTPUT
echo "WIN2022_VERSION=$WIN2022_VERSION" >> $env:GITHUB_OUTPUT
Write-Host "We have everything we need, continuing."
echo "CONTINUE=Yes" >> $env:GITHUB_OUTPUT
}
}
Write-Host "Getting OS versions for windows 2022 and 2019"
$win2019_manifest = (docker manifest inspect --verbose "octopuslabs/workertools:latest-windows.2019" | ConvertFrom-Json)
$WIN2019_VERSION = $win2019_manifest.Descriptor.Platform.'os.version'
Write-Host "WIN2019_VERSION: $WIN2019_VERSION"
$win2022_manifest = (docker manifest inspect --verbose "octopuslabs/workertools:latest-windows.2022" | ConvertFrom-Json)
$WIN2022_VERSION = $win2022_manifest.Descriptor.Platform.'os.version'
Write-Host "WIN2022_VERSION: $WIN2022_VERSION"
if([string]::IsNullOrWhiteSpace($WIN2019_VERSION) -or [string]::IsNullOrWhiteSpace($WIN2022_VERSION)) {
throw "Could not establish OS versions for windows 2022 and 2019 needed for docker manifest"
}
echo "WIN2019_VERSION=$WIN2019_VERSION" >> $env:GITHUB_OUTPUT
echo "WIN2022_VERSION=$WIN2022_VERSION" >> $env:GITHUB_OUTPUT
shell: powershell

build-ubuntu:
Expand Down

0 comments on commit 5eaab84

Please sign in to comment.