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
106 changes: 22 additions & 84 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,96 +102,34 @@ jobs:
winget:
needs: goreleaser
runs-on: windows-latest
env:
RELEASE_TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}

- 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/hubspot-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: |
$version = "${{ github.ref_name }}".TrimStart('v')
gh release download "${{ github.ref_name }}" --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 = "${{ github.ref_name }}".TrimStart('v')
$x64 = "https://github.com/open-cli-collective/hubspot-cli/releases/download/${{ github.ref_name }}/hspt_${version}_windows_amd64.zip"
$arm64 = "https://github.com/open-cli-collective/hubspot-cli/releases/download/${{ github.ref_name }}/hspt_${version}_windows_arm64.zip"

Write-Host "Updating existing manifest to version $version"
./wingetcreate.exe update OpenCLICollective.hubspot-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
- name: Resolve release version
id: version
shell: bash
run: |
$version = "${{ github.ref_name }}".TrimStart('v')
$manifestDir = "manifests"
New-Item -ItemType Directory -Path $manifestDir -Force | Out-Null

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

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

# Update installer manifest with version and real checksums
$installerManifest = Get-Content "packaging/winget/OpenCLICollective.hubspot-cli.installer.yaml" -Raw
$installerManifest = $installerManifest -replace "0\.0\.0", $version
# Replace checksums one at a time using .NET regex (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.hubspot-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"
set -euo pipefail
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Invalid release tag: $RELEASE_TAG"
exit 1
}
Write-Host "Validation passed!"
fi
echo "version=${RELEASE_TAG#v}" >> "$GITHUB_OUTPUT"

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 # open-cli-collective/.github#52
with:
package-id: OpenCLICollective.hubspot-cli
version: ${{ steps.version.outputs.version }}
final-tag: ${{ env.RELEASE_TAG }}
repo: ${{ github.repository }}
bootstrap: "true"
github-token: ${{ github.token }}
winget-token: ${{ secrets.WINGET_GITHUB_TOKEN }}

snap:
needs: goreleaser
Expand Down
4 changes: 2 additions & 2 deletions packaging/winget/OpenCLICollective.hubspot-cli.installer.yaml
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.hubspot-cli
PackageVersion: 0.0.0
Expand All @@ -15,4 +15,4 @@ Installers:
InstallerUrl: https://github.com/open-cli-collective/hubspot-cli/releases/download/v0.0.0/hspt_0.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.hubspot-cli
PackageVersion: 0.0.0
Expand All @@ -21,4 +21,4 @@ Tags:
- marketing
ReleaseNotesUrl: https://github.com/open-cli-collective/hubspot-cli/releases
ManifestType: defaultLocale
ManifestVersion: 1.10.0
ManifestVersion: 1.28.0
4 changes: 2 additions & 2 deletions packaging/winget/OpenCLICollective.hubspot-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.hubspot-cli
PackageVersion: 0.0.0
DefaultLocale: en-US
ManifestType: version
ManifestVersion: 1.10.0
ManifestVersion: 1.28.0
Loading