From a17ba669bfbf7c4c4defde782feae248c07f6fc8 Mon Sep 17 00:00:00 2001 From: Lance Pollard Date: Mon, 22 Jan 2024 22:26:28 -0800 Subject: [PATCH] save --- .github/workflows/choco.yaml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/choco.yaml b/.github/workflows/choco.yaml index ee41590..7acadd3 100644 --- a/.github/workflows/choco.yaml +++ b/.github/workflows/choco.yaml @@ -5,39 +5,46 @@ jobs: # Windows Server 2022 (https://github.com/actions/runner-images) runs-on: windows-2022 environment: build - if: $(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -Fqx choco.json && echo "true") == 'true' 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: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20.10.x - name: Set ENV vars + if: env.CHOCO_CHANGED == 'true' id: version run: | - echo "PACKAGE_VERSION=$(node -p "require('./choco.json').version")" >> $env:GITHUB_ENV + 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: