Skip to content

add winget publish step #63

add winget publish step

add winget publish step #63

name: Build and Package
on:
push:
branches: [main]
paths-ignore:
- "**.md"
- "LICENSE"
env:
APP_VERSION: "0.2.${{ github.run_number }}"
jobs:
build-and-package:
runs-on: windows-latest
steps:
- name: debug
run: "echo app version: $APP_VERSION"
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: dotnet publish
run: dotnet publish --self-contained -r win-x64 -f net8.0 -c release /p:Version=${{ env.APP_VERSION }}
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: binaries
path: bin\Release\net8.0\win-x64\publish\**
- name: Package
run: cd choco && choco pack --version ${{ env.APP_VERSION }}
- name: Upload nupkg
uses: actions/upload-artifact@v4
with:
name: nupkg
path: choco/*.nupkg
publish-choco:
if: github.ref == 'refs/heads/main'
needs: build-and-package
runs-on: windows-latest
steps:
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: nupkg
- name: publish to chocolatey community feed
env:
PUSH_URL: ${{ secrets.PUSH_URL }}
API_KEY: ${{ secrets.API_KEY }}
run: |
$nupkgs = Get-ChildItem . *.nupkg
foreach ($pkg in $nupkgs) {
Write-Host "Pushing: $($pkg.FullName) ..."
choco push "$($pkg.FullName)" -s "$env:PUSH_URL" -k "$env:API_KEY"
}
create-release:
needs:
- build-and-package
runs-on: ubuntu-latest
steps:
# - uses: actions/checkout@v2
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: binaries
path: bin
- name: Easy Zip Files
uses: vimtor/action-zip@v1
with:
dest: "Filesorter_${{ env.APP_VERSION }}.zip"
files: bin/
- name: Publish GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: "Filesorter_${{ env.APP_VERSION }}.zip"
artifactContentType: "application/zip"
tag: ${{ env.APP_VERSION }}
prerelease: ${{ github.ref != 'refs/heads/main'}}
token: ${{ secrets.GITHUB_TOKEN }}
publish-winget:
needs:
- create-release
runs-on: ubuntu-latest
steps:
- name: Update Packages
uses: michidk/winget-updater@v1
with:
komac-token: ${{ secrets.GITHUB_TOKEN }}
identifier: BC3Tech.FileSorter
repo: bc3tech/filesorter
url: https://github.com/bc3tech/filesorter/releases/download/{VERSION}/FileSorter_{VERSION}.zip