Skip to content

Commit

Permalink
Mapping image major for rc
Browse files Browse the repository at this point in the history
  • Loading branch information
thohng committed Oct 16, 2023
1 parent 08ea04a commit 8ca7d8b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
# { ver: 8.0-preview, arch: alpine3.18, matching: "8.0.0-preview" },
# { ver: 8.0-preview, arch: bookworm-slim, matching: "8.0.0-preview" },
# { ver: 8.0-preview, arch: jammy, matching: "8.0.0-preview" },
{ ver: "8.0", arch: alpine3.18, matching: "8.0.0-rc" },
{ ver: "8.0", arch: bookworm-slim, matching: "8.0.0-rc" },
{ ver: "8.0", arch: jammy, matching: "8.0.0-rc" },
{ ver: "8.0", arch: alpine3.18, matching: "8.0" },
{ ver: "8.0", arch: bookworm-slim, matching: "8.0" },
{ ver: "8.0", arch: jammy, matching: "8.0" },
# { ver: 8.0-preview, arch: jammy-chiseled, matching: "8.0.0-preview" },
]
name: ${{ matrix.image.ver }}-${{ matrix.image.arch }}
Expand Down
25 changes: 23 additions & 2 deletions docker-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ $mappingVersionArch = @{
'^8\.0\.0-preview[^-]+-jammy-chiseled$' = '8.0-preview-jammy-chiseled', '8.0-jammy-chiseled', 'jammy-chiseled'

'^8\.0\.0-rc[^-]+-alpine(.*)$' = '8.0-rc-alpine', '8.0-alpine', '8.0'
'^8\.0\.0-rc[^-]+-bookworm-slim$' = '8.0-rc-bookworm-slim', '8.0-rc', '8.0', 'bookworm-slim'
'^8\.0\.0-rc[^-]+-jammy$' = '8.0-rc-jammy', '8.0-rc', '8.0', 'jammy'
'^8\.0\.0-rc[^-]+-bookworm-slim$' = '8.0-rc-bookworm-slim', '8.0-rc', '8.0-bookworm-slim', '8.0', 'bookworm-slim'
'^8\.0\.0-rc[^-]+-jammy$' = '8.0-rc-jammy', '8.0-rc', '8.0-jammy', '8.0', 'jammy'
'^8\.0\.0-rc[^-]+-jammy-chiseled$' = '8.0-rc-jammy-chiseled', '8.0-jammy-chiseled', 'jammy-chiseled'

'^8\.0(\.\d+)?-alpine(.*)$' = '8.0-alpine', '8.0'
Expand All @@ -36,6 +36,13 @@ $mappingVersionArch = @{
'^8\.0(\.\d+)?-jammy-chiseled$' = '8.0-jammy-chiseled', 'jammy-chiseled'
}

$mappingMajorRc = @{
'^8\.0\.0-rc[^-]+-alpine(.*)$' = '8.0-alpine'
'^8\.0\.0-rc[^-]+-bookworm-slim$' = '8.0-bookworm-slim'
'^8\.0\.0-rc[^-]+-jammy$' = '8.0-jammy'
'^8\.0\.0-rc[^-]+-jammy-chiseled$' = '8.0-jammy-chiseled'
}

$latestTag = '6.0-alpine'

# sdkMajor mappings arch
Expand Down Expand Up @@ -71,13 +78,24 @@ function getVersionArch($imageTag) {
}
}

function getMajorRc($imageTag) {
foreach ($entry in $mappingMajorRc.GetEnumerator()) {
if ($imageTag -match $entry.Key) {
return [string] $entry.Value
}
}
}


$versionArches = getVersionArch $imageTag

$imageTagMajor = $versionArches | Select-Object -Index 0
if ($imageTagMajor) {
$imageArch = $mappingArch[$imageTagMajor]
}

$imageTagMajorRc = getMajorRc $imageTag

if (!$imageTag -or !$imageTagMajor -or !$imageArch) {
Write-Error "SDK Image Tag '$imageTag' is not supported" -ErrorAction Stop
}
Expand All @@ -91,6 +109,9 @@ foreach ($dockerRepos in $dockerRepository) {
if ($imageTag -ne $imageTagMajor) {
$dockerImages += @("$($dockerRepos):$($imageTagMajor)")
}
if ($imageTagMajorRc -and $imageTag -ne $imageTagMajorRc) {
$dockerImages += @("$($dockerRepos):$($imageTagMajorRc)")
}
if ($latestTag -eq $imageTagMajor -or $latestTag -eq $imageTag) {
$dockerImages += @("$($dockerRepos):latest")
}
Expand Down

0 comments on commit 8ca7d8b

Please sign in to comment.