Skip to content

Commit

Permalink
(kubernetes-cli) Update to the latest supported versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rgl committed Jul 25, 2022
1 parent c21e6fb commit a172847
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions automatic/kubernetes-cli/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,43 @@ function global:au_SearchReplace {
}

function global:au_GetLatest {
# Only report the supported Kubernetes streams.
# NB Upstream Kubernetes only supports the last three minor versions.
# However, they can also do pre-releases before a final version is
# released, so we have to check for an extra changelogs/minor
# version to be able to find all the supported streams.
# See https://github.com/kubernetes/sig-release/blob/master/release-engineering/versioning.md
$minor_versions_to_keep = 3

$changelog_page = Invoke-WebRequest -Uri $changelogs -UseBasicParsing
#Only the latest three minor versions are supported: https://github.com/kubernetes/sig-release/blob/master/release-engineering/versioning.md
#However, there are prereleases before the version is released, so the latest four changelogs/minor versions need to be checked.
$minor_version_changelogs = $changelog_page.links | ? href -match "CHANGELOG-[\d\.]+\.md" | Select-Object -Expand href -First 4
$minor_version_changelogs = $changelog_page.links `
| Where-Object href -match "CHANGELOG-(?<version>\d+\.\d+)\.md`$" `
| Select-Object -Expand href -First ($minor_versions_to_keep+1)

$streams = @{}

$minor_version_changelogs | ForEach-Object {
$minor_version = ($_ -split "CHANGELOG-" | Select-Object -Last 1).trim(".md")
$minor_changelog_page = Invoke-WebRequest -UseBasicParsing -Uri ("https://github.com" + $_)
$url64 = $minor_changelog_page.links | ? href -match "/v(?<version>[\d\.]+)/kubernetes-client-windows-amd64.tar.gz" | Select-Object -First 1 -Expand href
if ($_ -notmatch "CHANGELOG-(?<version>\d+\.\d+)\.md`$") {
return
}
$minor_version = $matches.version
$minor_changelog_page = Invoke-WebRequest -UseBasicParsing -Uri "https://github.com$_"
$url64 = $minor_changelog_page.links `
| Where-Object href -match "/v(?<version>\d+(\.\d+)+)/kubernetes-client-windows-amd64.tar.gz" `
| Select-Object -First 1 -Expand href
$patch_version = $matches.version
$url32 = $minor_changelog_page.links | ? href -match "/v[\d\.]+/kubernetes-client-windows-386.tar.gz" | Select-Object -First 1 -Expand href

if (!$url64) {
return
}
$url32 = $minor_changelog_page.links `
| Where-Object href -match "/v(?<version>\d+(\.\d+)+)/kubernetes-client-windows-386.tar.gz" `
| Select-Object -First 1 -Expand href

$streams.Add($minor_version, @{
Version = $patch_version
URL32 = $url32
URL64 = $url64
ReleaseNotes= ("https://github.com" + $_)
ReleaseNotes= "https://github.com$_"
})
}

Expand Down

0 comments on commit a172847

Please sign in to comment.