Choco Auto Update #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Choco Auto Update | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
update_choco_auto: | |
name: update_${{ matrix.package }} | |
runs-on: windows-latest | |
strategy: | |
max-parallel: 1 | |
matrix: | |
package: [ | |
wave | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Install Chocolatey Automatic Package Updater Module | |
run: Install-Module -Name Chocolatey-AU -Force | |
- name: Run ${{ matrix.package }} update script | |
id: update | |
run: | | |
cd ${{ matrix.package }} | |
$UpdateOutput = .\update.ps1 | |
$NupkgPath = (($UpdateOutput.Result | Where-Object {$_ -like '*.nupkg''*'}) -split "'")[1] | |
Write-Output "NupkgPath=$($NupkgPath)" >> $Env:GITHUB_OUTPUT | |
$UpdateStatus = if ($UpdateOutput.Result -match 'No new version found') {'No Update'} else {'Update Available'} | |
Write-Output "UpdateStatus=$($UpdateStatus)" >> $Env:GITHUB_OUTPUT | |
- name: Test ${{ matrix.package }} install | |
run: Test-Package -Install -Nu ${{ steps.update.outputs.NupkgPath }} | |
if: steps.update.outputs.UpdateStatus == 'Update Available' | |
- name: Publish to Chocolatey community feed | |
run: | | |
$Nupkg = '${{ steps.update.outputs.NupkgPath }}' | |
$ApiKey = '${{ secrets.CHOCOLATEY_API_KEY }}' | |
$ChocoServer = 'https://push.chocolatey.org/' | |
choco push $Nupkg --source $ChocoServer --key $ApiKey | |
if: steps.update.outputs.UpdateStatus == 'Update Available' | |
- name: Commit Updated nuspec | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Apply Choco package update - ${{ matrix.package }} ${{ steps.update.outputs.newversion }} | |
file_pattern: '*.nuspec *.ps1' | |
if: steps.update.outputs.UpdateStatus == 'Update Available' |