Skip to content

Workflow file for this run

on: push
jobs:
test:
# Windows Server 2022 (https://github.com/actions/runner-images)
runs-on: windows-2022
environment: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set CHOCO_CHANGED
run: echo "CHOCO_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -Fqx choco.json && echo \"true\")" >> $env:GITHUB_ENV
- name: Create cache directory
if: env.CHOCO_CHANGED == 'true'
run: mkdir "$($env:LOCALAPPDATA)\choco-cache"
- name: Cache Tools
if: env.CHOCO_CHANGED == 'true'
uses: actions/cache@v4
with:
path: "$($env:LOCALAPPDATA)\\choco-cache"
key: ${{ runner.os }}-temp-cache
- name: Set Choco cache path
if: env.CHOCO_CHANGED == 'true'
run: choco config set cacheLocation "$($env:LOCALAPPDATA)\choco-cache"
- name: Set ENV vars
if: env.CHOCO_CHANGED == 'true'
id: version
run: |
echo "PACKAGE_VERSION=$(cat choco.json | jq -r '.version')" >> $env:GITHUB_ENV
- name: Choco pack
if: env.CHOCO_CHANGED == 'true'
run: |
choco pack load/choco/task.nuspec --out load/choco
- name: Choco install
if: env.CHOCO_CHANGED == 'true'
run: |
choco install -y task --source "'./load/choco;chocolatey'"
- name: Choco set api key
if: env.CHOCO_CHANGED == 'true'
env:
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
run:
choco apikey --key $env:CHOCOLATEY_API_KEY --source https://push.chocolatey.org/
- name: Choco publish
if: env.CHOCO_CHANGED == 'true'
env:
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
run:
cd load/choco && choco push --key $env:CHOCOLATEY_API_KEY task.${{ env.PACKAGE_VERSION }}.nupkg --source
https://push.chocolatey.org/