Skip to content

Commit

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

Refactor (ci): Use new `versions.json` config
  • Loading branch information
leojonathanoh authored Sep 21, 2023
2 parents 89f5cfb + 8367e8e commit 4ad4736
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
13 changes: 2 additions & 11 deletions Update-Versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +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 = & {
$content = (Invoke-WebRequest https://sourceforge.net/p/isync/isync/ref/master/tags/).Content
[regex]::Matches($content, '/p/isync/isync/ci/v([^/]+)/tree/') | % { $_.Groups[1].Value } | 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
5 changes: 3 additions & 2 deletions generate/definitions/VARIANTS.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
$local:VERSIONS = @( Get-Content $PSScriptRoot/versions.json -Encoding utf8 -raw | ConvertFrom-Json )
$local:PACKAGE = 'isync'

# Docker image variants' definitions
$local:VARIANTS_MATRIX = @(
foreach ($v in $local:VERSIONS) {
foreach ($v in $local:VERSIONS.isync.versions) {
@{
package_version = $v
subvariants = @(
Expand Down Expand Up @@ -36,7 +37,7 @@ $VARIANTS = @(
$variant['package_version']
$subVariant['components'] | ? { $_ }
) -join '-'
tag_as_latest = if ($variant['package_version'] -eq $local:VERSIONS[0] -and $subVariant['components'].Count -eq 0) { $true } else { $false }
tag_as_latest = if ($variant['package_version'] -eq $local:VARIANTS_MATRIX[0]['package_version'] -and $subVariant['components'].Count -eq 0) { $true } else { $false }
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion generate/definitions/versions.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
["1.4.4"]
{
"isync": {
"versions": ["1.4.4"],
"versionsChangeScope": "minor",
"versionsNewScript": "$content = (Invoke-WebRequest https://sourceforge.net/p/isync/isync/ref/master/tags/).Content; [regex]::Matches($content, '/p/isync/isync/ci/v([^/]+)/tree/') | % { $_.Groups[1].Value } | Sort-Object { [version]$_ } -Descending"
}
}

0 comments on commit 4ad4736

Please sign in to comment.