Update And Publish Chocolatey Package #952
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: Update And Publish Chocolatey Package | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 9 * * *" | |
jobs: | |
check-update: | |
name: Check update | |
runs-on: windows-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.UPDATER }} | |
- name: Install au | |
shell: pwsh | |
run: Install-Module au -Force | |
- name: Check for new update | |
shell: pwsh | |
run: | | |
cd .\flow-launcher\ | |
.\update.ps1 | |
- name: Publish & commit new update | |
env: | |
API_KEY: ${{ secrets.PUBLISH }} | |
shell: pwsh | |
run: | | |
$ErrorActionPreference = "Stop" | |
git diff --exit-code | |
if ($LastExitCode -eq 1) | |
{ | |
cd .\flow-launcher\ | |
echo "`nNew update exists" | |
echo "`nPublishing new update to Chocolatey" | |
$api_key = $Env:api_key | |
$push_url = 'https://push.chocolatey.org' | |
$packages = Get-ChildItem *.nupkg | Sort-Object -Property CreationTime -Descending | |
if (!$All) { $packages = $packages | Select-Object -First 1 } | |
if (!$packages) { throw 'There is no nupkg file in the directory'} | |
$packages | ForEach-Object { choco push $_.Name --api-key $api_key --source $push_url } | |
echo "`nCommiting to Git" | |
git config --global user.email "[email protected]" | |
git config --global user.name "choco_package_updater" | |
git add .\flow-launcher.nuspec | |
git add .\tools\chocolateyinstall.ps1 | |
git commit -m 'new chocolatey package update' | |
git push | |
}elseif ($LastExitCode -eq 0) | |
{ | |
echo "`nNo new updates" | |
} | |
- name: Keep cron job alive during inactivity | |
uses: gautamkrishnar/keepalive-workflow@v1 |