Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ permissions:

jobs:
release:
uses: open-cli-collective/.github/.github/workflows/release.yml@v1
uses: open-cli-collective/.github/.github/workflows/release.yml@6ee65fbc893f13b8876f013ec0661219a3e18269
with:
# tag push is live (false); workflow_dispatch honors the checkbox. Compare
# against both true and 'true' because a workflow_dispatch boolean input
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/test-winget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install current WinGet validator
shell: pwsh
run: |
$bundle = Join-Path $env:RUNNER_TEMP "Microsoft.DesktopAppInstaller.msixbundle"
Invoke-WebRequest "https://github.com/microsoft/winget-cli/releases/download/v1.29.380/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -OutFile $bundle
$expected = "65dea9c01ce08ee7b763366b27c0e651f97db857c11ca9b9c301826c10092f2e"
if ((Get-FileHash $bundle -Algorithm SHA256).Hash -ne $expected) { throw "WinGet bundle checksum mismatch" }
$deps = Join-Path $env:RUNNER_TEMP "winget-dependencies.zip"
Invoke-WebRequest "https://github.com/microsoft/winget-cli/releases/download/v1.29.380/DesktopAppInstaller_Dependencies.zip" -OutFile $deps
$depsHash = "ba875afe9d190f61218985ac0292a99d1db710bf93e13c68944ca9d89f0d82d1"
if ((Get-FileHash $deps -Algorithm SHA256).Hash -ne $depsHash) { throw "WinGet dependencies checksum mismatch" }
$depsDir = Join-Path $env:RUNNER_TEMP "winget-dependencies"
Expand-Archive -Path $deps -DestinationPath $depsDir
$dependencyPaths = @(Get-ChildItem (Join-Path $depsDir "x64") -Filter "*.appx" | ForEach-Object FullName)
Add-AppxPackage -Path $bundle -DependencyPath $dependencyPaths
winget --version

- name: Validate manifest schema
shell: pwsh
run: |
Expand Down
113 changes: 14 additions & 99 deletions .github/workflows/winget-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,107 +8,22 @@ on:
required: true
type: string

permissions:
contents: read

jobs:
publish:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Validate release exists
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$release = gh release view "v${{ inputs.version }}" --json tagName 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Error "Release v${{ inputs.version }} not found"
exit 1
}
Write-Host "Found release v${{ inputs.version }}"

- name: Install wingetcreate
shell: pwsh
run: |
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe

- name: Check if manifest exists in winget-pkgs
id: check-manifest
shell: pwsh
run: |
$response = Invoke-WebRequest -Uri "https://api.github.com/repos/microsoft/winget-pkgs/contents/manifests/o/OpenCLICollective/newrelic-cli" -Method Head -SkipHttpErrorCheck
if ($response.StatusCode -eq 200) {
Write-Host "Manifest exists - will use wingetcreate update"
echo "exists=true" >> $env:GITHUB_OUTPUT
} else {
Write-Host "Manifest does not exist - will use wingetcreate new"
echo "exists=false" >> $env:GITHUB_OUTPUT
}

- name: Get checksums from release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download "v${{ inputs.version }}" --pattern "checksums.txt" --dir .

$checksums = Get-Content checksums.txt
$x64Hash = ($checksums | Select-String "windows_amd64.zip").Line.Split()[0]
$arm64Hash = ($checksums | Select-String "windows_arm64.zip").Line.Split()[0]

Write-Host "x64 SHA256: $x64Hash"
Write-Host "arm64 SHA256: $arm64Hash"

echo "X64_HASH=$x64Hash" >> $env:GITHUB_ENV
echo "ARM64_HASH=$arm64Hash" >> $env:GITHUB_ENV

- name: Update manifest (existing package)
if: steps.check-manifest.outputs.exists == 'true'
shell: pwsh
run: |
$version = "${{ inputs.version }}"
$x64 = "https://github.com/open-cli-collective/newrelic-cli/releases/download/v${version}/nrq_v${version}_windows_amd64.zip"
$arm64 = "https://github.com/open-cli-collective/newrelic-cli/releases/download/v${version}/nrq_v${version}_windows_arm64.zip"

Write-Host "Updating existing manifest to version $version"
./wingetcreate.exe update OpenCLICollective.newrelic-cli --version $version --urls $x64 $arm64 --submit --token ${{ secrets.WINGET_GITHUB_TOKEN }}

- name: Create manifest (new package)
if: steps.check-manifest.outputs.exists == 'false'
shell: pwsh
run: |
$version = "${{ inputs.version }}"
$manifestDir = "manifests"
New-Item -ItemType Directory -Path $manifestDir -Force | Out-Null

# Update version manifest
$versionManifest = Get-Content "packaging/winget/OpenCLICollective.newrelic-cli.yaml" -Raw
$versionManifest = $versionManifest -replace "0\.0\.0", $version
Set-Content "$manifestDir/OpenCLICollective.newrelic-cli.yaml" $versionManifest

# Update locale manifest
$localeManifest = Get-Content "packaging/winget/OpenCLICollective.newrelic-cli.locale.en-US.yaml" -Raw
$localeManifest = $localeManifest -replace "0\.0\.0", $version
Set-Content "$manifestDir/OpenCLICollective.newrelic-cli.locale.en-US.yaml" $localeManifest

# Update installer manifest with version and real checksums
$installerManifest = Get-Content "packaging/winget/OpenCLICollective.newrelic-cli.installer.yaml" -Raw
$installerManifest = $installerManifest -replace "0\.0\.0", $version
# Use .NET regex for sequential replacement (PowerShell -replace doesn't support count)
$regex = [regex]"0{64}"
$installerManifest = $regex.Replace($installerManifest, $env:X64_HASH, 1)
$installerManifest = $regex.Replace($installerManifest, $env:ARM64_HASH, 1)
Set-Content "$manifestDir/OpenCLICollective.newrelic-cli.installer.yaml" $installerManifest

Write-Host "Generated manifests:"
Get-ChildItem $manifestDir | ForEach-Object { Write-Host " $_" }

Write-Host "`nValidating manifests..."
winget validate --manifest $manifestDir
if ($LASTEXITCODE -ne 0) {
Write-Error "Manifest validation failed"
exit 1
}
Write-Host "Validation passed!"

Write-Host "`nSubmitting new package to Winget..."
./wingetcreate.exe submit --token ${{ secrets.WINGET_GITHUB_TOKEN }} $manifestDir
- name: Submit WinGet package
uses: open-cli-collective/.github/actions/winget-submit@6ee65fbc893f13b8876f013ec0661219a3e18269
with:
package-id: OpenCLICollective.newrelic-cli
version: ${{ inputs.version }}
final-tag: v${{ inputs.version }}
repo: ${{ github.repository }}
working-directory: .
bootstrap: "true"
github-token: ${{ github.token }}
winget-token: ${{ secrets.WINGET_GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.10.0.schema.json
# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.28.0.schema.json

PackageIdentifier: OpenCLICollective.newrelic-cli
PackageVersion: 0.0.0
Expand All @@ -15,4 +15,4 @@ Installers:
InstallerUrl: https://github.com/open-cli-collective/newrelic-cli/releases/download/v0.0.0/nrq_v0.0.0_windows_arm64.zip
InstallerSha256: 0000000000000000000000000000000000000000000000000000000000000000
ManifestType: installer
ManifestVersion: 1.10.0
ManifestVersion: 1.28.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.10.0.schema.json
# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.28.0.schema.json

PackageIdentifier: OpenCLICollective.newrelic-cli
PackageVersion: 0.0.0
Expand Down Expand Up @@ -35,4 +35,4 @@ Tags:
- sre
ReleaseNotesUrl: https://github.com/open-cli-collective/newrelic-cli/releases
ManifestType: defaultLocale
ManifestVersion: 1.10.0
ManifestVersion: 1.28.0
4 changes: 2 additions & 2 deletions packaging/winget/OpenCLICollective.newrelic-cli.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.10.0.schema.json
# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.28.0.schema.json

PackageIdentifier: OpenCLICollective.newrelic-cli
PackageVersion: 0.0.0
DefaultLocale: en-US
ManifestType: version
ManifestVersion: 1.10.0
ManifestVersion: 1.28.0
Loading