# Publish to Windows Package Manager (winget)
#
# PREREQUISITES:
# 1. CCExtractor must already have ONE version in winget-pkgs before this works
#    - Submit the initial manifest manually from packaging/winget/
#    - PR to: https://github.com/microsoft/winget-pkgs
#
# 2. Create a fork of microsoft/winget-pkgs under the CCExtractor organization
#    - https://github.com/CCExtractor/winget-pkgs (needs to be created)
#
# 3. Create a GitHub Personal Access Token (classic) with 'public_repo' scope
#    - Add as repository secret: WINGET_TOKEN
#
# Reference: https://github.com/vedantmgoyal9/winget-releaser

name: Publish to WinGet

on:
  release:
    types: [released]
  workflow_dispatch:
    inputs:
      release_tag:
        description: 'Release tag to publish (e.g., v0.96.1)'
        required: true
        type: string

jobs:
  publish:
    runs-on: windows-latest
    steps:
      - name: Publish to WinGet
        uses: vedantmgoyal9/winget-releaser@v2
        with:
          identifier: CCExtractor.CCExtractor
          installers-regex: '\.msi$'  # Only use the MSI installer
          token: ${{ secrets.WINGET_TOKEN }}
          release-tag: ${{ github.event.inputs.release_tag || github.event.release.tag_name }}
