Skip to content

Commit

Permalink
Refactor (ci): Use new versions.json config
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Sep 21, 2023
1 parent 179fc9a commit be3e2fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
10 changes: 2 additions & 8 deletions Update-Versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,10 @@ 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/powershell/powershell/git/refs/tags | ConvertFrom-Json | % { $_.ref -replace 'refs/tags/v', ''} | ? { $_ -match '^\d+\.\d+\.\d+$' } | Sort-Object { [version]$_ } -Descending
# 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
$prs = Update-DockerImageVariantsVersions -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
$return = Update-DockerImageVariantsVersions -VersionsChanged $versionsChanged -PR:$PR -AutoMergeQueue:$AutoMergeQueue -AutoRelease:$AutoRelease -AutoReleaseTagConvention $AutoReleaseTagConvention -WhatIf:$WhatIfPreference
$return = Update-DockerImageVariantsVersions -PR:$PR -AutoMergeQueue:$AutoMergeQueue -AutoRelease:$AutoRelease -AutoReleaseTagConvention $AutoReleaseTagConvention -WhatIf:$WhatIfPreference
}catch {
throw
}finally {
Expand Down
4 changes: 2 additions & 2 deletions generate/definitions/VARIANTS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $local:VERSIONS = @( Get-Content $PSScriptRoot/versions.json -Encoding utf8 -raw
$local:BASE_IMAGE_TAGS = @(
$r = Invoke-RestMethod https://mcr.microsoft.com/v2/powershell/tags/list

foreach ($v in $local:VERSIONS) {
foreach ($v in $local:VERSIONS.pwsh.versions) {
$v = [version]$v
$r.tags | ? { $_ -match "^(lts-)?$( $v.Major )\.$( $v.Minor )(\.\d+)?-alpine-\d+\.\d+" } | Select-Object -Last 1
}
Expand All @@ -13,7 +13,7 @@ $local:BASE_IMAGE_TAGS = @(
'6.2.4-alpine-3.8'
'6.1.3-alpine-3.8'

foreach ($v in $local:VERSIONS) {
foreach ($v in $local:VERSIONS.pwsh.versions) {
$v = [version]$v
$r.tags | ? { $_ -match "^(lts-)?$( $v.Major )\.$( $v.Minor )(\.\d+)?-ubuntu-\d+\.\d+$" } | Select-Object -Last 1
}
Expand Down
11 changes: 7 additions & 4 deletions generate/definitions/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[
"7.3.7",
"7.2.14"
]
{
"pwsh": {
"versions": ["7.3.7", "7.2.14"],
"versionsChangeScope": "minor",
"versionsNewScript": "Invoke-WebRequest https://api.github.com/repos/powershell/powershell/git/refs/tags | ConvertFrom-Json | % { $_.ref -replace 'refs/tags/v', ''} | ? { $_ -match '^\\d+\\.\\d+\\.\\d+$' } | Sort-Object { [version]$_ } -Descending"
}
}

0 comments on commit be3e2fc

Please sign in to comment.