From 8b1faa0552fd6cd4db628f9771b6fa47b0a86857 Mon Sep 17 00:00:00 2001 From: Erik Mogensen Date: Mon, 15 Jul 2024 21:48:24 +0200 Subject: [PATCH] Add publishing to winget (#795) * Add publishing to winget * New version of action checkout Co-authored-by: Sean Feldman --- .github/workflows/handle-tag.yml | 2 +- .github/workflows/winget-submission.yml | 32 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/winget-submission.yml diff --git a/.github/workflows/handle-tag.yml b/.github/workflows/handle-tag.yml index 658e8851..86362c85 100644 --- a/.github/workflows/handle-tag.yml +++ b/.github/workflows/handle-tag.yml @@ -19,7 +19,7 @@ jobs: echo $hash - name: Checkout main - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: main diff --git a/.github/workflows/winget-submission.yml b/.github/workflows/winget-submission.yml new file mode 100644 index 00000000..a08b1480 --- /dev/null +++ b/.github/workflows/winget-submission.yml @@ -0,0 +1,32 @@ +name: WinGet submission on release +# based off of https://github.com/microsoft/PowerToys/blob/main/.github/workflows/package-submissions.yml and https://github.com/microsoft/terminal/blob/main/.github/workflows/winget.yml + +on: + release: + types: [published] + +env: + VERSION_REGEX: 'ServiceBusExplorer-([\d.]+)(?:-preview)?\.zip$' + +jobs: + winget: + name: Publish winget package + runs-on: windows-2022 + steps: + - name: Submit PaoloSalvatori.ServiceBusExplorer ${{ github.event.release.prerelease && 'Preview' || 'Stable' }} + run: | + + $assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json + $wingetRelevantAsset = $assets | Where-Object { $_.name -like '*.zip' } | Select-Object -First 1 + $regex = [Regex]::New($env:VERSION_REGEX) + $version = $regex.Match($wingetRelevantAsset.name).Groups[1].Value + + $wingetPackage = "PaoloSalvatori.ServiceBusExplorer${{ github.event.release.prerelease && '.Preview' || '' }}" + + # Get the latest wingetcreate file + Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe + + # Submit a PR for the package + .\wingetcreate.exe update $wingetPackage --submit --version $version --urls $wingetRelevantAsset.browser_download_url --token "${{ secrets.GITHUB_TOKEN }}" + + \ No newline at end of file