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
53 changes: 48 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,59 @@ jobs:
run: |
Invoke-WebRequest -Uri https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe

- name: Check winget package status
id: winget_status
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$packagePath = 'manifests/j/jmanuelcorral/SquadCenter'
$headers = @{ 'User-Agent' = 'jmanuelcorral/squadcenter-release' }
$response = Invoke-WebRequest `
-Uri "https://api.github.com/repos/microsoft/winget-pkgs/contents/$packagePath" `
-Headers $headers `
-SkipHttpErrorCheck

if ($response.StatusCode -eq 200) {
echo "EXISTS=true" >> $env:GITHUB_OUTPUT
Write-Host "winget package already exists; using wingetcreate update."
} elseif ($response.StatusCode -eq 404) {
echo "EXISTS=false" >> $env:GITHUB_OUTPUT
Write-Host "winget package does not exist yet; submitting local manifest as the initial package."
} else {
throw "Unable to determine winget package status. GitHub API returned $($response.StatusCode)."
}

- name: Submit winget manifest
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$packageId = 'jmanuelcorral.SquadCenter'
$version = "${{ steps.version.outputs.VERSION }}"
$url = "https://github.com/jmanuelcorral/squadcenter/releases/download/v${version}/Squad-Center-Setup-${version}.exe"
.\wingetcreate.exe update jmanuelcorral.SquadCenter `
--version $version `
--urls $url `
--submit `
--token $env:WINGET_TOKEN
$manifestPath = Join-Path $PWD 'winget\jmanuelcorral.SquadCenter.yaml'

if ([string]::IsNullOrWhiteSpace($env:WINGET_TOKEN)) {
throw "WINGET_TOKEN is required. Create a GitHub PAT with repo/public_repo access, an expiration of 90 days or less, and SSO authorization for microsoft/winget-pkgs."
}

if ("${{ steps.winget_status.outputs.EXISTS }}" -eq 'true') {
.\wingetcreate.exe update $packageId `
--version $version `
--urls $url `
--submit `
--token $env:WINGET_TOKEN `
--no-open `
--prtitle "$packageId version $version"
} else {
.\wingetcreate.exe submit $manifestPath `
--token $env:WINGET_TOKEN `
--no-open `
--prtitle "New package: $packageId version $version"
}

if ($LASTEXITCODE -ne 0) {
throw "wingetcreate failed. If the error mentions Microsoft Open Source PAT lifetime policy or SAML SSO, rotate WINGET_TOKEN to a GitHub PAT with an expiration of 90 days or less and authorize SSO for microsoft/winget-pkgs."
}
env:
WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ choco install squad-center
winget install jmanuelcorral.SquadCenter
```

> WinGet availability depends on Microsoft accepting the package submission in
> `microsoft/winget-pkgs`. If the package is not found yet, use GitHub Releases,
> Chocolatey, or npm while the initial submission is pending.

#### 🐧 apt (Debian/Ubuntu)
```bash
# Add the GPG key
Expand Down
8 changes: 4 additions & 4 deletions winget/jmanuelcorral.SquadCenter.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://aka.ms/winget-manifest.singleton.1.6.0.schema.json
PackageIdentifier: jmanuelcorral.SquadCenter
PackageVersion: 0.2.0
PackageVersion: 0.3.1
PackageLocale: en-US
Publisher: jmanuelcorral
PublisherUrl: https://github.com/jmanuelcorral
Expand All @@ -18,9 +18,9 @@ Tags:
- electron
Installers:
- Architecture: x64
InstallerType: nsis
InstallerUrl: https://github.com/jmanuelcorral/squadcenter/releases/download/v0.2.0/Squad-Center-Setup-0.2.0.exe
InstallerSha256: ""
InstallerType: nullsoft
InstallerUrl: https://github.com/jmanuelcorral/squadcenter/releases/download/v0.3.1/Squad-Center-Setup-0.3.1.exe
InstallerSha256: 617A998F0BE23D6B5AB5FF4786ED23F6949BBF97BFD5BDAB84C4516F9B0A0D6C
InstallerSwitches:
Silent: /S
SilentWithProgress: /S
Expand Down
12 changes: 9 additions & 3 deletions winget/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@ $manifestPath = Join-Path $PSScriptRoot 'jmanuelcorral.SquadCenter.yaml'
Write-Host "Updating winget manifest to version $Version ..."

$content = Get-Content $manifestPath -Raw
$installerUrl = "https://github.com/jmanuelcorral/squadcenter/releases/download/v${Version}/Squad-Center-Setup-${Version}.exe"

# Update PackageVersion
$content = $content -replace '(?<=PackageVersion:\s)[\d]+\.[\d]+\.[\d]+', $Version
$content = $content -replace '(?m)^PackageVersion:\s.*$', "PackageVersion: $Version"

# Update InstallerUrl
$content = $content -replace 'v[\d]+\.[\d]+\.[\d]+/Squad-Center-Setup-[\d]+\.[\d]+\.[\d]+\.exe', "v${Version}/Squad-Center-Setup-${Version}.exe"
$content = $content -replace '(?m)^ InstallerUrl:\s.*$', " InstallerUrl: $installerUrl"

# Update InstallerSha256
if ($Sha256) {
$content = $content -replace '(?<=InstallerSha256:\s).*', $Sha256
$normalizedSha = $Sha256.Trim().ToUpperInvariant()
if ($normalizedSha -notmatch '^[A-F0-9]{64}$') {
throw "Invalid SHA256 value: $Sha256"
}

$content = $content -replace '(?m)^ InstallerSha256:\s.*$', " InstallerSha256: $normalizedSha"
}

Set-Content -Path $manifestPath -Value $content -NoNewline -Encoding UTF8
Expand Down