ci: Make each package build in a separate task using a generated matrix

This commit is contained in:
Adam Goldsmith 2023-03-25 15:49:08 -04:00
parent 7a260f2314
commit 62dbf0ae0c

View File

@ -7,19 +7,30 @@ env:
NUGET_URL: https://git.claremontmakerspace.org/api/packages/${{ github.repository_owner }}/nuget/index.json
jobs:
Build-Chocolatey-Packages:
List-Packages:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: set-matrix
run: echo "matrix=$(find . -name '*.nuspec' -printf '%h\n' | sed 's|^./||g' | jq -Rsc 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
Build-Chocolatey-Packages:
needs: List-Packages
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
strategy:
matrix:
package: ${{ fromJson(needs.List-Packages.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Chocolatey Pack
run: docker run --rm -v "$PWD/${{ matrix.package }}:/build" -w /build chocolatey/choco choco pack
- name: Chocolatey Push
run: |
for package in */
do
echo "Packing $package"
docker run --rm -v "$PWD/$package:/build" -w /build chocolatey/choco choco pack
docker run --rm -v "$PWD/$package:/build" -w /build chocolatey/choco choco push \
docker run --rm -v "$PWD/${{ matrix.package }}:/build" -w /build chocolatey/choco choco push \
--source "${{ env.NUGET_URL }}" --key "${{ secrets.GITHUB_TOKEN }}"
done