Skip to content

Commit

Permalink
Merge pull request #1952 from rgl/rgl-update-kubernetes-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm authored Aug 2, 2022
2 parents cc6542e + 66d5224 commit ecd690b
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions automatic/kubernetes-cli/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,45 @@ function global:au_SearchReplace {
}

function global:au_GetLatest {
# Only report the supported Kubernetes streams.

$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


# There is quite a few versions that do not exist on chocolatey.org
# and since the limit of pushed packages is 10, we need to limit the amount
# of streams that we parse. Once packages are approved we can increase/remove
# the limit.
$minor_version_changelogs = $changelog_page.links `
| Where-Object href -match "CHANGELOG-(?<version>\d+\.\d+)\.md`$" `
| Select-Object -Expand href -First 10

$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
if ($streams.ContainsKey($minor_version)) {
return
}
$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 ecd690b

Please sign in to comment.