Skip to content

Commit 845b16e

Browse files
committed
Update publish workflow to support new version format and enhance installer URL handling
1 parent f8860d6 commit 845b16e

File tree

1 file changed

+52
-38
lines changed

1 file changed

+52
-38
lines changed

.github/workflows/publish-winget.yml

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77
inputs:
88
version:
9-
description: 'Netbird version to publish (e.g., 0.59.7)'
9+
description: 'Netbird version to publish (e.g., 0.59.8)'
1010
required: true
1111
type: string
1212

@@ -18,88 +18,102 @@ jobs:
1818
uses: actions/checkout@v4
1919

2020
- name: Set up WingetCreate
21+
shell: pwsh
2122
run: |
2223
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
2324
2425
- name: Determine version
2526
id: version
27+
shell: pwsh
2628
run: |
2729
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
2830
$version = "${{ github.event.inputs.version }}"
2931
} else {
30-
# Extract version from release tag (remove 'v' prefix if present)
3132
$version = "${{ github.event.release.tag_name }}".TrimStart('v')
3233
}
33-
echo "VERSION=$version" >> $env:GITHUB_ENV
34-
echo "version=$version" >> $env:GITHUB_OUTPUT
34+
"VERSION=$version" >> $env:GITHUB_ENV
35+
"version=$version" >> $env:GITHUB_OUTPUT
3536
36-
- name: Fetch release info
37+
- name: Fetch release info & collect installer URLs
3738
id: release_info
39+
shell: pwsh
3840
env:
3941
GH_API: https://api.github.com
4042
WINGET_PAT: ${{ secrets.WINGET_PAT }}
4143
run: |
4244
$ErrorActionPreference = 'Stop'
4345
4446
$headers = @{
45-
Authorization = "Bearer $env:WINGET_PAT"
46-
"User-Agent" = "netbird-winget-action"
47-
Accept = "application/vnd.github+json"
48-
"X-GitHub-Api-Version"= "2022-11-28"
47+
Authorization = "Bearer $env:WINGET_PAT"
48+
"User-Agent" = "netbird-winget-action"
49+
Accept = "application/vnd.github+json"
50+
"X-GitHub-Api-Version" = "2022-11-28"
4951
}
5052
5153
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
52-
# For manual dispatch, fetch release info from GitHub API
5354
$release = Invoke-RestMethod -Headers $headers -Uri "$env:GH_API/repos/netbirdio/netbird/releases/tags/v${{ env.VERSION }}"
5455
} else {
55-
# For release event, use the current release
5656
$release = Invoke-RestMethod -Headers $headers -Uri "${{ github.event.release.url }}"
5757
}
5858
59-
$urls = @(
60-
($assets | Where-Object { $_.name -like "*windows_amd64.msi" } | Select-Object -ExpandProperty browser_download_url -First 1),
61-
($assets | Where-Object { $_.name -like "*windows_amd64.exe" } | Select-Object -ExpandProperty browser_download_url -First 1),
62-
($assets | Where-Object { $_.name -like "*windows_arm64.msi" } | Select-Object -ExpandProperty browser_download_url -First 1),
63-
($assets | Where-Object { $_.name -like "*windows_arm64.exe" } | Select-Object -ExpandProperty browser_download_url -First 1)
64-
) | Where-Object { $_ }
65-
66-
if (-not $urls -or $urls.Count -eq 0) {
67-
throw "No Windows installers found in v${{ env.VERSION }}."
59+
# IMPORTANT: set $assets
60+
$assets = $release.assets
61+
if (-not $assets) {
62+
throw "Release v${{ env.VERSION }} has no assets (is the tag correct and the build finished?)."
6863
}
6964
70-
# Pick a primary (x64 MSI) for consumers that expect a single URL
71-
$primary = $urls | Where-Object { $_ -like "*.msi" -and $_ -match "amd64" } | Select-Object -First 1
72-
if (-not $primary) { $primary = $urls[0] }
65+
# Collect MSI & EXE installers for x64 and arm64
66+
$msi_x64 = $assets | Where-Object { $_.name -like "*windows_amd64.msi" } | Select-Object -ExpandProperty browser_download_url -First 1
67+
$exe_x64 = $assets | Where-Object { $_.name -like "*windows_amd64.exe" } | Select-Object -ExpandProperty browser_download_url -First 1
68+
$msi_arm = $assets | Where-Object { $_.name -like "*windows_arm64.msi" } | Select-Object -ExpandProperty browser_download_url -First 1
69+
$exe_arm = $assets | Where-Object { $_.name -like "*windows_arm64.exe" } | Select-Object -ExpandProperty browser_download_url -First 1
70+
71+
# At least one installer must exist
72+
$any = @($msi_x64, $exe_x64, $msi_arm, $exe_arm) | Where-Object { $_ }
73+
if (-not $any -or $any.Count -eq 0) {
74+
throw "No Windows installers (MSI/EXE) found in v${{ env.VERSION }}."
75+
}
7376
74-
# Output: single-line
75-
"installer_url=$primary" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
77+
# Qualify with architecture to help WingetCreate match correctly
78+
# (WingetCreate also matches by installer type automatically)
79+
$qualified = @()
80+
if ($msi_x64) { $qualified += "$msi_x64|x64" }
81+
if ($exe_x64) { $qualified += "$exe_x64|x64" }
82+
if ($msi_arm) { $qualified += "$msi_arm|arm64" }
83+
if ($exe_arm) { $qualified += "$exe_arm|arm64" }
7684
77-
# Output: multiline list of all installer URLs
78-
$delimUrls = "EOF_$([Guid]::NewGuid().ToString('N'))"
79-
Add-Content $env:GITHUB_OUTPUT "installer_urls<<$delimUrls"
80-
$urls | ForEach-Object { Add-Content $env:GITHUB_OUTPUT $_ }
81-
Add-Content $env:GITHUB_OUTPUT $delimUrls
85+
# Persist for next step; also expose a primary for logs
86+
Set-Content -Path installer_urls.txt -Value ($qualified -join "`n")
87+
"installer_urls_file=installer_urls.txt" >> $env:GITHUB_OUTPUT
88+
"installer_url=$($any[0])" >> $env:GITHUB_OUTPUT
8289
83-
# Output: release notes (multiline; normalize to LF)
90+
# (Optional) release notes, normalized to LF
8491
$notes = ($release.body ?? "") -replace "`r",""
8592
$delimNotes = "EOF_$([Guid]::NewGuid().ToString('N'))"
8693
Add-Content $env:GITHUB_OUTPUT "release_notes<<$delimNotes"
8794
Add-Content $env:GITHUB_OUTPUT $notes
8895
Add-Content $env:GITHUB_OUTPUT $delimNotes
8996
9097
- name: Update Winget Manifest
98+
shell: pwsh
99+
env:
100+
WINGET_PAT: ${{ secrets.WINGET_PAT }}
91101
run: |
92-
Write-Host "Updating Winget manifest for Netbird version ${{ env.VERSION }}"
93-
Write-Host "Installer URL: ${{ steps.release_info.outputs.installer_url }}"
94-
95-
# Use wingetcreate to update and submit the manifest
102+
Write-Host "Updating Winget manifest for Netbird ${{ env.VERSION }}"
103+
Write-Host "Example installer: ${{ steps.release_info.outputs.installer_url }}"
104+
105+
$urls = Get-Content "${{ steps.release_info.outputs.installer_urls_file }}" | Where-Object { $_.Trim() }
106+
if (-not $urls) { throw "No installer URLs to submit." }
107+
108+
# Pass ALL MSI+EXE installers to match the existing multi-installer manifest
96109
.\wingetcreate.exe update Netbird.Netbird `
97-
--version ${{ env.VERSION }} `
98-
--urls ${{ steps.release_info.outputs.installer_url }} `
110+
--version $env:VERSION `
111+
--urls $urls `
99112
--submit `
100-
--token ${{ secrets.WINGET_PAT }} `
113+
--token $env:WINGET_PAT
101114
102115
- name: Verify submission
116+
shell: pwsh
103117
run: |
104118
if ($LASTEXITCODE -eq 0) {
105119
Write-Host "✅ Successfully submitted Winget manifest update for Netbird ${{ env.VERSION }}"

0 commit comments

Comments
 (0)