From 8b97938845489e537eb2b34110d9f4e2c2338e60 Mon Sep 17 00:00:00 2001 From: Rian Stockbower Date: Fri, 25 Sep 2026 11:14:27 -0400 Subject: [PATCH 1/6] fix(cfl): render static Chocolatey URLs --- .github/workflows/chocolatey-publish-cfl.yml | 13 ++++-- .github/workflows/test-chocolatey.yml | 43 ++++++++++++++++--- .../chocolatey/tools/chocolateyInstall.ps1 | 13 +++--- 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/.github/workflows/chocolatey-publish-cfl.yml b/.github/workflows/chocolatey-publish-cfl.yml index aa44e669..e398d816 100644 --- a/.github/workflows/chocolatey-publish-cfl.yml +++ b/.github/workflows/chocolatey-publish-cfl.yml @@ -48,10 +48,15 @@ jobs: - name: Update install script URLs run: | $version = "${{ inputs.version }}" - $script = Get-Content tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 - $script = $script -replace 'https://github.com/open-cli-collective/confluence-cli/', 'https://github.com/open-cli-collective/atlassian-cli/' - $script = $script -replace '/v\$\{version\}', "/cfl-v`${version}" - $script | Set-Content tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 + $scriptPath = 'tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1' + $script = Get-Content $scriptPath -Raw + $amd64Url = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_amd64.zip" + $arm64Url = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_arm64.zip" + if (-not $script.Contains('URL_AMD64_PLACEHOLDER')) { throw 'Missing URL_AMD64_PLACEHOLDER' } + if (-not $script.Contains('URL_ARM64_PLACEHOLDER')) { throw 'Missing URL_ARM64_PLACEHOLDER' } + $script = $script.Replace('URL_AMD64_PLACEHOLDER', $amd64Url) + $script = $script.Replace('URL_ARM64_PLACEHOLDER', $arm64Url) + Set-Content $scriptPath $script - name: Pack and push run: | diff --git a/.github/workflows/test-chocolatey.yml b/.github/workflows/test-chocolatey.yml index 7c9ff03c..1d9f4d16 100644 --- a/.github/workflows/test-chocolatey.yml +++ b/.github/workflows/test-chocolatey.yml @@ -34,14 +34,43 @@ jobs: } Write-Host "Install script syntax is valid" - - name: Test pack (dry run) + - name: Test rendered package + shell: pwsh run: | - cd tools/cfl/packaging/chocolatey - # Update version for test - $nuspec = Get-Content confluence-cli.nuspec - $nuspec = $nuspec -replace '.*', '0.0.1-test' - $nuspec | Set-Content confluence-cli.nuspec - choco pack --verbose + $version = '0.0.1-test' + $packageDir = 'tools/cfl/packaging/chocolatey' + $nuspecPath = Join-Path $packageDir 'confluence-cli.nuspec' + $nuspec = (Get-Content $nuspecPath -Raw).Replace('0.0.0', "$version") + Set-Content $nuspecPath $nuspec + + $scriptPath = Join-Path $packageDir 'tools/chocolateyInstall.ps1' + $script = Get-Content $scriptPath -Raw + $script = $script.Replace('URL_AMD64_PLACEHOLDER', "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_amd64.zip") + $script = $script.Replace('URL_ARM64_PLACEHOLDER', "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_arm64.zip") + $script = $script.Replace('CHECKSUM_AMD64_PLACEHOLDER', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + $script = $script.Replace('CHECKSUM_ARM64_PLACEHOLDER', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') + Set-Content $scriptPath $script + + Push-Location $packageDir + try { + choco pack --verbose + } finally { + Pop-Location + } + + $packagePath = Join-Path $packageDir "confluence-cli.$version.nupkg" + if (-not (Test-Path $packagePath)) { throw "Expected package was not created: $packagePath" } + $extractDir = Join-Path $env:RUNNER_TEMP "cfl-choco-$([guid]::NewGuid())" + Expand-Archive -Path $packagePath -DestinationPath $extractDir + $renderedPath = Join-Path $extractDir 'tools/chocolateyInstall.ps1' + $rendered = Get-Content $renderedPath -Raw + if ($rendered -match 'URL_AMD64_PLACEHOLDER|URL_ARM64_PLACEHOLDER|CHECKSUM_AMD64_PLACEHOLDER|CHECKSUM_ARM64_PLACEHOLDER|ChocolateyPackageVersion|\$\{version\}') { + throw 'Rendered cfl package still contains a URL/checksum placeholder or runtime package-version expression' + } + $expectedAmd64 = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_amd64.zip" + $expectedArm64 = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_arm64.zip" + if (-not $rendered.Contains($expectedAmd64)) { throw "Rendered package is missing $expectedAmd64" } + if (-not $rendered.Contains($expectedArm64)) { throw "Rendered package is missing $expectedArm64" } test-jtk: runs-on: windows-latest diff --git a/tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 b/tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 index 13b5e4e6..ab5f85b2 100644 --- a/tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 +++ b/tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 @@ -1,28 +1,27 @@ $ErrorActionPreference = 'Stop' -$version = $env:ChocolateyPackageVersion $toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition -# Checksums injected by release workflow - DO NOT EDIT MANUALLY +# URLs and checksums injected by release workflow - DO NOT EDIT MANUALLY +$urlAmd64 = 'URL_AMD64_PLACEHOLDER' +$urlArm64 = 'URL_ARM64_PLACEHOLDER' $checksumAmd64 = 'CHECKSUM_AMD64_PLACEHOLDER' $checksumArm64 = 'CHECKSUM_ARM64_PLACEHOLDER' # Architecture detection with ARM64 support if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'arm64' + $url = $urlArm64 $checksum = $checksumArm64 } elseif ([Environment]::Is64BitOperatingSystem) { $arch = 'amd64' + $url = $urlAmd64 $checksum = $checksumAmd64 } else { throw "32-bit Windows is not supported. confluence-cli requires 64-bit Windows." } -$baseUrl = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v${version}" -$zipFile = "cfl_${version}_windows_${arch}.zip" -$url = "${baseUrl}/${zipFile}" - -Write-Host "Installing confluence-cli ${version} for Windows ${arch}..." +Write-Host "Installing confluence-cli for Windows ${arch}..." Write-Host "URL: ${url}" Write-Host "Checksum (SHA256): ${checksum}" From 7b2a94ad96e0bfd06abcbb971475a6b8516615e7 Mon Sep 17 00:00:00 2001 From: Rian Stockbower Date: Fri, 25 Sep 2026 11:17:28 -0400 Subject: [PATCH 2/6] test(cfl): validate rendered Chocolatey package --- .github/workflows/chocolatey-publish-cfl.yml | 5 +++++ .github/workflows/test-chocolatey.yml | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/chocolatey-publish-cfl.yml b/.github/workflows/chocolatey-publish-cfl.yml index e398d816..006867a3 100644 --- a/.github/workflows/chocolatey-publish-cfl.yml +++ b/.github/workflows/chocolatey-publish-cfl.yml @@ -56,6 +56,11 @@ jobs: if (-not $script.Contains('URL_ARM64_PLACEHOLDER')) { throw 'Missing URL_ARM64_PLACEHOLDER' } $script = $script.Replace('URL_AMD64_PLACEHOLDER', $amd64Url) $script = $script.Replace('URL_ARM64_PLACEHOLDER', $arm64Url) + if ($script -match 'URL_AMD64_PLACEHOLDER|URL_ARM64_PLACEHOLDER|CHECKSUM_AMD64_PLACEHOLDER|CHECKSUM_ARM64_PLACEHOLDER|ChocolateyPackageVersion|\$\{version\}') { + throw 'Rendered cfl install script still contains a URL/checksum placeholder or runtime package-version expression' + } + if (-not $script.Contains($amd64Url)) { throw "Rendered script is missing $amd64Url" } + if (-not $script.Contains($arm64Url)) { throw "Rendered script is missing $arm64Url" } Set-Content $scriptPath $script - name: Pack and push diff --git a/.github/workflows/test-chocolatey.yml b/.github/workflows/test-chocolatey.yml index 1d9f4d16..c0067a76 100644 --- a/.github/workflows/test-chocolatey.yml +++ b/.github/workflows/test-chocolatey.yml @@ -5,6 +5,9 @@ on: branches: [main] paths: - 'tools/*/packaging/chocolatey/**' + pull_request: + paths: + - 'tools/*/packaging/chocolatey/**' jobs: test-cfl: @@ -61,7 +64,7 @@ jobs: $packagePath = Join-Path $packageDir "confluence-cli.$version.nupkg" if (-not (Test-Path $packagePath)) { throw "Expected package was not created: $packagePath" } $extractDir = Join-Path $env:RUNNER_TEMP "cfl-choco-$([guid]::NewGuid())" - Expand-Archive -Path $packagePath -DestinationPath $extractDir + [IO.Compression.ZipFile]::ExtractToDirectory($packagePath, $extractDir) $renderedPath = Join-Path $extractDir 'tools/chocolateyInstall.ps1' $rendered = Get-Content $renderedPath -Raw if ($rendered -match 'URL_AMD64_PLACEHOLDER|URL_ARM64_PLACEHOLDER|CHECKSUM_AMD64_PLACEHOLDER|CHECKSUM_ARM64_PLACEHOLDER|ChocolateyPackageVersion|\$\{version\}') { From dc0369c564961e377ed15d2fdeb299029f4056bf Mon Sep 17 00:00:00 2001 From: Rian Stockbower Date: Fri, 25 Sep 2026 11:26:15 -0400 Subject: [PATCH 3/6] test(cfl): exercise rendered Chocolatey installer --- .github/workflows/chocolatey-publish-cfl.yml | 29 ++------- .github/workflows/test-chocolatey.yml | 60 +++++++++++++++++-- .../cfl/scripts/render-chocolatey-install.ps1 | 41 +++++++++++++ 3 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 tools/cfl/scripts/render-chocolatey-install.ps1 diff --git a/.github/workflows/chocolatey-publish-cfl.yml b/.github/workflows/chocolatey-publish-cfl.yml index 006867a3..cff01f58 100644 --- a/.github/workflows/chocolatey-publish-cfl.yml +++ b/.github/workflows/chocolatey-publish-cfl.yml @@ -38,30 +38,13 @@ jobs: $nuspec = $nuspec -replace '.*', "$version" $nuspec | Set-Content tools/cfl/packaging/chocolatey/confluence-cli.nuspec - - name: Update install script checksums + - name: Render install script run: | - $script = Get-Content tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 - $script = $script -replace "CHECKSUM_AMD64_PLACEHOLDER", $env:CHECKSUM_AMD64 - $script = $script -replace "CHECKSUM_ARM64_PLACEHOLDER", $env:CHECKSUM_ARM64 - $script | Set-Content tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 - - - name: Update install script URLs - run: | - $version = "${{ inputs.version }}" - $scriptPath = 'tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1' - $script = Get-Content $scriptPath -Raw - $amd64Url = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_amd64.zip" - $arm64Url = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_arm64.zip" - if (-not $script.Contains('URL_AMD64_PLACEHOLDER')) { throw 'Missing URL_AMD64_PLACEHOLDER' } - if (-not $script.Contains('URL_ARM64_PLACEHOLDER')) { throw 'Missing URL_ARM64_PLACEHOLDER' } - $script = $script.Replace('URL_AMD64_PLACEHOLDER', $amd64Url) - $script = $script.Replace('URL_ARM64_PLACEHOLDER', $arm64Url) - if ($script -match 'URL_AMD64_PLACEHOLDER|URL_ARM64_PLACEHOLDER|CHECKSUM_AMD64_PLACEHOLDER|CHECKSUM_ARM64_PLACEHOLDER|ChocolateyPackageVersion|\$\{version\}') { - throw 'Rendered cfl install script still contains a URL/checksum placeholder or runtime package-version expression' - } - if (-not $script.Contains($amd64Url)) { throw "Rendered script is missing $amd64Url" } - if (-not $script.Contains($arm64Url)) { throw "Rendered script is missing $arm64Url" } - Set-Content $scriptPath $script + pwsh -File tools/cfl/scripts/render-chocolatey-install.ps1 ` + -Version "${{ inputs.version }}" ` + -ScriptPath tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 ` + -ChecksumAmd64 $env:CHECKSUM_AMD64 ` + -ChecksumArm64 $env:CHECKSUM_ARM64 - name: Pack and push run: | diff --git a/.github/workflows/test-chocolatey.yml b/.github/workflows/test-chocolatey.yml index c0067a76..94609b67 100644 --- a/.github/workflows/test-chocolatey.yml +++ b/.github/workflows/test-chocolatey.yml @@ -5,9 +5,15 @@ on: branches: [main] paths: - 'tools/*/packaging/chocolatey/**' + - 'tools/cfl/scripts/**' + - '.github/workflows/chocolatey-publish-cfl.yml' + - '.github/workflows/test-chocolatey.yml' pull_request: paths: - 'tools/*/packaging/chocolatey/**' + - 'tools/cfl/scripts/**' + - '.github/workflows/chocolatey-publish-cfl.yml' + - '.github/workflows/test-chocolatey.yml' jobs: test-cfl: @@ -47,12 +53,13 @@ jobs: Set-Content $nuspecPath $nuspec $scriptPath = Join-Path $packageDir 'tools/chocolateyInstall.ps1' - $script = Get-Content $scriptPath -Raw - $script = $script.Replace('URL_AMD64_PLACEHOLDER', "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_amd64.zip") - $script = $script.Replace('URL_ARM64_PLACEHOLDER', "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$version/cfl_${version}_windows_arm64.zip") - $script = $script.Replace('CHECKSUM_AMD64_PLACEHOLDER', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') - $script = $script.Replace('CHECKSUM_ARM64_PLACEHOLDER', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') - Set-Content $scriptPath $script + $checksumAmd64 = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef' + $checksumArm64 = 'fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210' + pwsh -File tools/cfl/scripts/render-chocolatey-install.ps1 ` + -Version $version ` + -ScriptPath $scriptPath ` + -ChecksumAmd64 $checksumAmd64 ` + -ChecksumArm64 $checksumArm64 Push-Location $packageDir try { @@ -75,6 +82,47 @@ jobs: if (-not $rendered.Contains($expectedAmd64)) { throw "Rendered package is missing $expectedAmd64" } if (-not $rendered.Contains($expectedArm64)) { throw "Rendered package is missing $expectedArm64" } + function Install-ChocolateyZipPackage { + param( + [string]$PackageName, + [string]$Url, + [string]$UnzipLocation, + [string]$Checksum, + [string]$ChecksumType + ) + $script:capturedPackageName = $PackageName + $script:capturedUrl = $Url + $script:capturedChecksum = $Checksum + $script:capturedChecksumType = $ChecksumType + } + + $env:ChocolateyPackageName = 'confluence-cli' + $architectures = @( + @{ Name = 'AMD64'; Environment = 'AMD64'; Url = $expectedAmd64; Checksum = $checksumAmd64 }, + @{ Name = 'ARM64'; Environment = 'ARM64'; Url = $expectedArm64; Checksum = $checksumArm64 } + ) + foreach ($architecture in $architectures) { + $previousArchitecture = $env:PROCESSOR_ARCHITECTURE + try { + $env:PROCESSOR_ARCHITECTURE = $architecture.Environment + $script:capturedUrl = $null + $script:capturedChecksum = $null + $script:capturedChecksumType = $null + & $renderedPath + } finally { + $env:PROCESSOR_ARCHITECTURE = $previousArchitecture + } + if ($script:capturedUrl -ne $architecture.Url) { + throw "$($architecture.Name) selected URL '$script:capturedUrl', expected '$($architecture.Url)'" + } + if ($script:capturedChecksum -ne $architecture.Checksum) { + throw "$($architecture.Name) selected checksum '$script:capturedChecksum', expected '$($architecture.Checksum)'" + } + if ($script:capturedChecksumType -ne 'sha256') { + throw "$($architecture.Name) selected checksum type '$script:capturedChecksumType', expected 'sha256'" + } + } + test-jtk: runs-on: windows-latest steps: diff --git a/tools/cfl/scripts/render-chocolatey-install.ps1 b/tools/cfl/scripts/render-chocolatey-install.ps1 new file mode 100644 index 00000000..6d7615ce --- /dev/null +++ b/tools/cfl/scripts/render-chocolatey-install.ps1 @@ -0,0 +1,41 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory)] + [string]$Version, + + [Parameter(Mandatory)] + [string]$ScriptPath, + + [Parameter(Mandatory)] + [ValidatePattern('^[0-9a-fA-F]{64}$')] + [string]$ChecksumAmd64, + + [Parameter(Mandatory)] + [ValidatePattern('^[0-9a-fA-F]{64}$')] + [string]$ChecksumArm64 +) + +$ErrorActionPreference = 'Stop' + +$amd64Url = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$Version/cfl_${Version}_windows_amd64.zip" +$arm64Url = "https://github.com/open-cli-collective/atlassian-cli/releases/download/cfl-v$Version/cfl_${Version}_windows_arm64.zip" +$script = Get-Content $ScriptPath -Raw + +foreach ($placeholder in 'URL_AMD64_PLACEHOLDER', 'URL_ARM64_PLACEHOLDER', 'CHECKSUM_AMD64_PLACEHOLDER', 'CHECKSUM_ARM64_PLACEHOLDER') { + if (-not $script.Contains($placeholder)) { throw "Missing $placeholder in $ScriptPath" } +} + +$script = $script.Replace('URL_AMD64_PLACEHOLDER', $amd64Url) +$script = $script.Replace('URL_ARM64_PLACEHOLDER', $arm64Url) +$script = $script.Replace('CHECKSUM_AMD64_PLACEHOLDER', $ChecksumAmd64) +$script = $script.Replace('CHECKSUM_ARM64_PLACEHOLDER', $ChecksumArm64) + +if ($script -match 'URL_AMD64_PLACEHOLDER|URL_ARM64_PLACEHOLDER|CHECKSUM_AMD64_PLACEHOLDER|CHECKSUM_ARM64_PLACEHOLDER|ChocolateyPackageVersion|\$\{version\}') { + throw "Rendered $ScriptPath still contains a URL/checksum placeholder or runtime package-version expression" +} +if (-not $script.Contains($amd64Url)) { throw "Rendered script is missing $amd64Url" } +if (-not $script.Contains($arm64Url)) { throw "Rendered script is missing $arm64Url" } +if (-not $script.Contains($ChecksumAmd64)) { throw "Rendered script is missing the AMD64 checksum" } +if (-not $script.Contains($ChecksumArm64)) { throw "Rendered script is missing the ARM64 checksum" } + +Set-Content $ScriptPath $script From 798feccbf83a11996cc21ef04a50821bb1529f3b Mon Sep 17 00:00:00 2001 From: Rian Stockbower Date: Fri, 25 Sep 2026 11:27:27 -0400 Subject: [PATCH 4/6] test(cfl): capture stubbed installer arguments --- .github/workflows/test-chocolatey.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-chocolatey.yml b/.github/workflows/test-chocolatey.yml index 94609b67..155dbf7f 100644 --- a/.github/workflows/test-chocolatey.yml +++ b/.github/workflows/test-chocolatey.yml @@ -90,10 +90,10 @@ jobs: [string]$Checksum, [string]$ChecksumType ) - $script:capturedPackageName = $PackageName - $script:capturedUrl = $Url - $script:capturedChecksum = $Checksum - $script:capturedChecksumType = $ChecksumType + $global:capturedPackageName = $PackageName + $global:capturedUrl = $Url + $global:capturedChecksum = $Checksum + $global:capturedChecksumType = $ChecksumType } $env:ChocolateyPackageName = 'confluence-cli' @@ -105,21 +105,21 @@ jobs: $previousArchitecture = $env:PROCESSOR_ARCHITECTURE try { $env:PROCESSOR_ARCHITECTURE = $architecture.Environment - $script:capturedUrl = $null - $script:capturedChecksum = $null - $script:capturedChecksumType = $null + $global:capturedUrl = $null + $global:capturedChecksum = $null + $global:capturedChecksumType = $null & $renderedPath } finally { $env:PROCESSOR_ARCHITECTURE = $previousArchitecture } - if ($script:capturedUrl -ne $architecture.Url) { - throw "$($architecture.Name) selected URL '$script:capturedUrl', expected '$($architecture.Url)'" + if ($global:capturedUrl -ne $architecture.Url) { + throw "$($architecture.Name) selected URL '$global:capturedUrl', expected '$($architecture.Url)'" } - if ($script:capturedChecksum -ne $architecture.Checksum) { - throw "$($architecture.Name) selected checksum '$script:capturedChecksum', expected '$($architecture.Checksum)'" + if ($global:capturedChecksum -ne $architecture.Checksum) { + throw "$($architecture.Name) selected checksum '$global:capturedChecksum', expected '$($architecture.Checksum)'" } - if ($script:capturedChecksumType -ne 'sha256') { - throw "$($architecture.Name) selected checksum type '$script:capturedChecksumType', expected 'sha256'" + if ($global:capturedChecksumType -ne 'sha256') { + throw "$($architecture.Name) selected checksum type '$global:capturedChecksumType', expected 'sha256'" } } From bd2e2eb5f619ad281db40c3156db68b697fdd0c4 Mon Sep 17 00:00:00 2001 From: Rian Stockbower Date: Fri, 25 Sep 2026 11:29:18 -0400 Subject: [PATCH 5/6] ci(cfl): validate manual release version --- .github/workflows/chocolatey-publish-cfl.yml | 20 ++++++++++++++----- .../cfl/scripts/render-chocolatey-install.ps1 | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/chocolatey-publish-cfl.yml b/.github/workflows/chocolatey-publish-cfl.yml index cff01f58..9c9e8c1d 100644 --- a/.github/workflows/chocolatey-publish-cfl.yml +++ b/.github/workflows/chocolatey-publish-cfl.yml @@ -11,20 +11,29 @@ on: jobs: publish: runs-on: windows-latest + env: + VERSION: ${{ inputs.version }} steps: - uses: actions/checkout@v4 + - name: Validate version + shell: pwsh + run: | + if ($env:VERSION -notmatch '^[0-9]+\.[0-9]+\.[0-9]+$') { + throw "Version must be numeric SemVer (major.minor.patch): $env:VERSION" + } + - name: Download release assets env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - $version = "${{ inputs.version }}" + $version = $env:VERSION $tag = "cfl-v$version" gh release download $tag --pattern "cfl_${version}_windows_*.zip" --pattern "checksums.txt" --dir artifacts - name: Extract checksums run: | - $version = "${{ inputs.version }}" + $version = $env:VERSION $checksums = Get-Content artifacts/checksums.txt $amd64 = ($checksums | Select-String "cfl_${version}_windows_amd64.zip").ToString().Split(" ")[0] $arm64 = ($checksums | Select-String "cfl_${version}_windows_arm64.zip").ToString().Split(" ")[0] @@ -33,7 +42,7 @@ jobs: - name: Update nuspec version run: | - $version = "${{ inputs.version }}" + $version = $env:VERSION $nuspec = Get-Content tools/cfl/packaging/chocolatey/confluence-cli.nuspec $nuspec = $nuspec -replace '.*', "$version" $nuspec | Set-Content tools/cfl/packaging/chocolatey/confluence-cli.nuspec @@ -41,7 +50,7 @@ jobs: - name: Render install script run: | pwsh -File tools/cfl/scripts/render-chocolatey-install.ps1 ` - -Version "${{ inputs.version }}" ` + -Version $env:VERSION ` -ScriptPath tools/cfl/packaging/chocolatey/tools/chocolateyInstall.ps1 ` -ChecksumAmd64 $env:CHECKSUM_AMD64 ` -ChecksumArm64 $env:CHECKSUM_ARM64 @@ -50,4 +59,5 @@ jobs: run: | cd tools/cfl/packaging/chocolatey choco pack - choco push confluence-cli.${{ inputs.version }}.nupkg --source https://push.chocolatey.org/ --api-key ${{ secrets.CHOCOLATEY_API_KEY }} + $package = "confluence-cli.$($env:VERSION).nupkg" + choco push $package --source https://push.chocolatey.org/ --api-key ${{ secrets.CHOCOLATEY_API_KEY }} diff --git a/tools/cfl/scripts/render-chocolatey-install.ps1 b/tools/cfl/scripts/render-chocolatey-install.ps1 index 6d7615ce..53edbb2f 100644 --- a/tools/cfl/scripts/render-chocolatey-install.ps1 +++ b/tools/cfl/scripts/render-chocolatey-install.ps1 @@ -1,6 +1,7 @@ [CmdletBinding()] param( [Parameter(Mandatory)] + [ValidatePattern('^[0-9]+\.[0-9]+\.[0-9]+$')] [string]$Version, [Parameter(Mandatory)] From 1ec6f02535877b658e51bfe00fd59b3dd3c02c11 Mon Sep 17 00:00:00 2001 From: Rian Stockbower Date: Fri, 25 Sep 2026 11:30:11 -0400 Subject: [PATCH 6/6] test(cfl): use numeric package version fixture --- .github/workflows/test-chocolatey.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-chocolatey.yml b/.github/workflows/test-chocolatey.yml index 155dbf7f..8379bd45 100644 --- a/.github/workflows/test-chocolatey.yml +++ b/.github/workflows/test-chocolatey.yml @@ -46,7 +46,7 @@ jobs: - name: Test rendered package shell: pwsh run: | - $version = '0.0.1-test' + $version = '0.0.1' $packageDir = 'tools/cfl/packaging/chocolatey' $nuspecPath = Join-Path $packageDir 'confluence-cli.nuspec' $nuspec = (Get-Content $nuspecPath -Raw).Replace('0.0.0', "$version")