Skip to content

Commit

Permalink
Merge pull request #107 from theohbrothers/refactor/ci-use-new-versio…
Browse files Browse the repository at this point in the history
…ns.json-config

Refactor (ci): Use new `versions.json` config
  • Loading branch information
leojonathanoh authored Sep 21, 2023
2 parents 1f7d0e1 + 86bccbb commit 4305f27
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 33 deletions.
14 changes: 0 additions & 14 deletions Update-Versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ try {
Push-Location $repo
}

# Get my versions from generate/definitions/versions.json
$versions = Get-Content $PSScriptRoot/generate/definitions/versions.json -Encoding utf8 | ConvertFrom-Json
# Get new versions
$versionsNew = @(
Invoke-WebRequest https://api.github.com/repos/kubernetes/kubernetes/git/refs/tags | ConvertFrom-Json | % { $_.ref -replace 'refs/tags/v', ''} | ? { $_ -match '^\d+\.\d+\.\d+$' } | Sort-Object { [version]$_ } -Descending
# & {
# $y = (Invoke-WebRequest https://raw.githubusercontent.com/kubernetes/website/main/data/releases/schedule.yaml).Content | ConvertFrom-Yaml
# $y.schedules | % { $_.next.release }
# $y = (Invoke-WebRequest https://raw.githubusercontent.com/kubernetes/website/main/data/releases/eol.yaml).Content | ConvertFrom-Yaml
# $y.branches | % { $_.finalPatchRelease }
# }
)
# Get changed versions
$versionsChanged = Get-VersionsChanged -Versions $versions -VersionsNew $versionsNew -AsObject -Descending
# Update versions.json, and open PRs with CI disabled
$prs = Update-DockerImageVariantsVersions -VersionsChanged $versionsChanged -CommitPreScriptblock { Move-Item .github .github.disabled -Force } -PR:$PR -WhatIf:$WhatIfPreference
# Update versions.json, update PRs with CI, merge PRs one at a time, release and close milestone
Expand Down
4 changes: 2 additions & 2 deletions generate/definitions/VARIANTS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ $local:VERSIONS = @( Get-Content $PSScriptRoot/versions.json -Encoding utf8 -raw

# Docker image variants' definitions
$local:VARIANTS_MATRIX = @(
foreach ($v in $local:VERSIONS) {
foreach ($v in $local:VERSIONS.kubectl.versions) {
@{
package_version = "v$v"
distro = 'alpine'
distro_version = '3.15'
subvariants = @(
@{ components = @(); tag_as_latest = if ($v -eq ($local:VERSIONS | ? { $_ -match '^\d+\.\d+\.\d+$' } | Select-Object -First 1 )) { $true } else { $false } }
@{ components = @(); tag_as_latest = if ($v -eq ($local:VERSIONS.kubectl.versions | ? { $_ -match '^\d+\.\d+\.\d+$' } | Select-Object -First 1 )) { $true } else { $false } }
@{ components = @( 'envsubst', 'git', 'jq', 'kustomize', 'sops', 'ssh' ) }
)
}
Expand Down
40 changes: 23 additions & 17 deletions generate/definitions/versions.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
[
"1.28.2",
"1.27.6",
"1.26.9",
"1.25.14",
"1.24.17",
"1.23.17",
"1.22.17",
"1.21.14",
"1.20.15",
"1.19.16",
"1.18.20",
"1.17.17",
"1.16.15",
"1.15.12",
"1.14.10"
]
{
"kubectl": {
"versions": [
"1.28.2",
"1.27.6",
"1.26.9",
"1.25.14",
"1.24.17",
"1.23.17",
"1.22.17",
"1.21.14",
"1.20.15",
"1.19.16",
"1.18.20",
"1.17.17",
"1.16.15",
"1.15.12",
"1.14.10"
],
"versionsChangeScope": "minor",
"versionsNewScript": "Invoke-WebRequest https://api.github.com/repos/kubernetes/kubernetes/git/refs/tags | ConvertFrom-Json | % { $_.ref -replace 'refs/tags/v', ''} | ? { $_ -match '^\\d+\\.\\d+\\.\\d+$' } | Sort-Object { [version]$_ } -Descending # Alternative, but not updated promptly despite release on github.com/kubernetes/kubernetes: $y = (Invoke-WebRequest https://raw.githubusercontent.com/kubernetes/website/main/data/releases/schedule.yaml).Content | ConvertFrom-Yaml; $y.schedules | % { $_.next.release }; $y = (Invoke-WebRequest https://raw.githubusercontent.com/kubernetes/website/main/data/releases/eol.yaml).Content | ConvertFrom-Yaml;Z$y.branches | % { $_.finalPatchRelease }"
}
}

0 comments on commit 4305f27

Please sign in to comment.