From cf3589f272a49d112a930b7d2f012804e4d82d4f Mon Sep 17 00:00:00 2001 From: Mitchell Syer Date: Sun, 5 Jul 2026 14:23:43 -0400 Subject: [PATCH] Improve winget action (#2164) --- .github/workflows/winget.yml | 37 ++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml index 8e90a2f65..de7b7962a 100644 --- a/.github/workflows/winget.yml +++ b/.github/workflows/winget.yml @@ -1,19 +1,52 @@ name: Publish to WinGet + on: workflow_dispatch: inputs: version: description: Version required: false + type: string + release: + types: [published] jobs: publish: runs-on: windows-latest # action can only be run on windows steps: + - uses: actions/checkout@v4 + + - name: Determine version + id: version + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + if [ -n "${{ inputs.version }}" ]; then + VERSION="${{ inputs.version }}" + elif [ "${{ github.event_name }}" = "release" ]; then + VERSION="${{ github.event.release.tag_name }}" + else + VERSION="$(gh release view --json tagName -q .tagName)" + fi + + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Sync winget-pkgs fork with upstream + shell: bash + env: + GH_TOKEN: ${{ secrets.WINGET_PUBLISH_PAT }} + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/Suwayomi/winget-pkgs/merge-upstream" \ + -f branch=master + - uses: vedantmgoyal2009/winget-releaser@v2 with: identifier: Suwayomi.Suwayomi-Server installers-regex: '.*x64.msi$' token: ${{ secrets.WINGET_PUBLISH_PAT }} - version: ${{ inputs.version || github.ref_name }} - release-tag: ${{ inputs.version || github.ref_name }} + version: ${{ steps.version.outputs.version }} + release-tag: ${{ steps.version.outputs.version }} \ No newline at end of file