Helpers to use with Generate-DockerImageVariants.
Open powershell
or pwsh
and type:
Install-Module -Name Generate-DockerImageVariantsHelpers -Repository PSGallery -Scope CurrentUser -Verbose
If prompted to trust the repository, hit Y
and enter
.
All required modules are automatically installed:
Import the module, and the cmdlets will be available. For example:
Import-Module Generate-DockerImageVariantsHelpers
# Clone the current repo to a temporary directory
$repo = Clone-TempRepo
cd $repo
# Create generate/definitions/versions.json
New-DockerImageVariantsVersions -Package coolpackage -VersionsChangeScope minor -VersionsNewScript { Invoke-RestMethod https://example.com/versions.json } #-Whatif
New-DockerImageVariantsVersions -Package coolpackage -VersionsChangeScope patch -VersionsNewScript { Invoke-RestMethod https://example.com/versions.json } #-Whatif
# Get generate/definitions/versions.json
$versionsConfig = Get-DockerImageVariantsVersions
# Set generate/definitions/versions.json
Set-DockerImageVariantsVersions @{
coolpackage = @{
versions = @(
'0.1.0'
'0.2.0'
)
versionsChangeScope = 'minor'
versionsNewScript = 'Invoke-RestMethod https://example.com/versions.json'
}
} #-WhatIf
# Execute commands
{ git status } | Execute-Command -ErrorAction Stop #-WhatIf
# Get changed versions
$versionsChanged = Get-VersionsChanged -Versions @( '0.1.0' ) -VersionsNew @( '0.1.1', '0.2.0' ) -ChangeScope patch -AsObject
$versionsChanged = Get-VersionsChanged -Versions @( '0.1.0' ) -VersionsNew @( '0.1.1', '0.2.0' ) -ChangeScope minor -AsObject
# Open PR for each changed version
$env:GITHUB_TOKEN = 'xxx'
$prs = @(
foreach ($c in $versionsChanged.Values) {
if ($c['kind'] -eq 'new') {
New-DockerImageVariantsPR -Package coolpackage -Version $c['to'] -Verb add #-WhatIf
}
if ($c['kind'] -eq 'update') {
New-DockerImageVariantsPR -Package coolpackage -Version $c['from'] -VersionNew $c['to'] -Verb update #-WhatIf
}
}
)
# Merge each successful PR one after another
$env:GITHUB_TOKEN = 'xxx'
foreach ($pr in $prs) {
$pr = Automerge-DockerImageVariantsPR -PR $pr #-WhatIf
}
# Update ./generate/definitions/versions.json and open a PR for each changed version, and merge successful PRs one after another (to prevent merge conflicts)
$env:GITHUB_TOKEN = 'xxx'
$autoMergeResults = Update-DockerImageVariantsVersions -PR -AutoMergeQueue #-WhatIf
# Update ./generate/definitions/versions.json and open a PR for each changed version, and merge successful PRs one after another (to prevent merge conflicts), and create a tagged release and close milestone
$autoMergeResults = Update-DockerImageVariantsVersions -PR -AutoMergeQueue -AutoRelease -AutoReleaseTagConvention calver #-WhatIf
$autoMergeResults = Update-DockerImageVariantsVersions -PR -AutoMergeQueue -AutoRelease -AutoReleaseTagConvention semver #-WhatIf
# Get next tag
$tag = Get-TagNext -TagConvention calver
$tag = Get-TagNext -TagConvention semver
# Tag <tag>, push new <tag>, rename milestone 'next-release' to <tag>, and close milestone
$env:GITHUB_TOKEN = 'xxx'
$tag = New-Release -TagConvention calver #-WhatIf
$tag = New-Release -TagConvention semver #-WhatIf