|
| 1 | +name: Publish Netbird to Winget |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: 'Netbird version to publish (e.g., 0.59.7)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + |
| 13 | +jobs: |
| 14 | + publish-winget: |
| 15 | + runs-on: windows-latest |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up WingetCreate |
| 21 | + run: | |
| 22 | + Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe |
| 23 | +
|
| 24 | + - name: Determine version |
| 25 | + id: version |
| 26 | + run: | |
| 27 | + if ("${{ github.event_name }}" -eq "workflow_dispatch") { |
| 28 | + $version = "${{ github.event.inputs.version }}" |
| 29 | + } else { |
| 30 | + # Extract version from release tag (remove 'v' prefix if present) |
| 31 | + $version = "${{ github.event.release.tag_name }}".TrimStart('v') |
| 32 | + } |
| 33 | + echo "VERSION=$version" >> $env:GITHUB_ENV |
| 34 | + echo "version=$version" >> $env:GITHUB_OUTPUT |
| 35 | +
|
| 36 | + - name: Fetch release info |
| 37 | + id: release_info |
| 38 | + run: | |
| 39 | + if ("${{ github.event_name }}" -eq "workflow_dispatch") { |
| 40 | + # For manual dispatch, fetch release info from GitHub API |
| 41 | + $release = Invoke-RestMethod -Uri "https://api.github.com/repos/netbirdio/netbird/releases/tags/v${{ env.VERSION }}" |
| 42 | + } else { |
| 43 | + # For release event, use the current release |
| 44 | + $release = Invoke-RestMethod -Uri "${{ github.event.release.url }}" |
| 45 | + } |
| 46 | + |
| 47 | + # Find MSI installer URL |
| 48 | + $installerUrl = $release.assets | Where-Object { $_.name -like "*windows_amd64.msi" } | Select-Object -ExpandProperty browser_download_url |
| 49 | + |
| 50 | + if (-not $installerUrl) { |
| 51 | + Write-Error "No MSI installer found for version ${{ env.VERSION }}" |
| 52 | + exit 1 |
| 53 | + } |
| 54 | + |
| 55 | + echo "installer_url=$installerUrl" >> $env:GITHUB_OUTPUT |
| 56 | + echo "release_notes=$($release.body)" >> $env:GITHUB_OUTPUT |
| 57 | +
|
| 58 | + - name: Update Winget Manifest |
| 59 | + run: | |
| 60 | + Write-Host "Updating Winget manifest for Netbird version ${{ env.VERSION }}" |
| 61 | + Write-Host "Installer URL: ${{ steps.release_info.outputs.installer_url }}" |
| 62 | + |
| 63 | + # Use wingetcreate to update and submit the manifest |
| 64 | + .\wingetcreate.exe update netbirdio.netbird ` |
| 65 | + --version ${{ env.VERSION }} ` |
| 66 | + --urls ${{ steps.release_info.outputs.installer_url }} ` |
| 67 | + --submit ` |
| 68 | + --token ${{ secrets.WINGET_PAT }} ` |
| 69 | + --description "NetBird is an open-source VPN management platform built on WireGuard® making it easy to create secure private networks for your organization." |
| 70 | +
|
| 71 | + - name: Verify submission |
| 72 | + run: | |
| 73 | + if ($LASTEXITCODE -eq 0) { |
| 74 | + Write-Host "✅ Successfully submitted Winget manifest update for Netbird ${{ env.VERSION }}" |
| 75 | + } else { |
| 76 | + Write-Error "❌ Failed to submit Winget manifest update" |
| 77 | + exit 1 |
| 78 | + } |
0 commit comments