diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65f3397..7006dd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,17 +10,11 @@ jobs: generate-matrix: name: "Generate matrix from cabal" runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - name: Checkout base repo - uses: actions/checkout@v4 - - name: Extract the tested GHC versions - id: set-matrix - run: | - wget https://github.com/Kleidukos/get-tested/releases/download/v0.1.5.0/get-tested-0.1.5.0-linux-amd64 -O get-tested - chmod +x get-tested - ./get-tested --ubuntu --macos get-tested.cabal >> $GITHUB_OUTPUT + - name: Generate matrix + uses: turion/get-tested@v0.1.5.0 + with: + cabal-file: get-tested.cabal tests: name: ${{ matrix.ghc }} on ${{ matrix.os }} needs: generate-matrix diff --git a/README.md b/README.md index 27dc4f6..066b77f 100644 --- a/README.md +++ b/README.md @@ -7,26 +7,18 @@ A CLI tool that retrieves the `tested-with` stanza of a cabal file and formats i Put this in your GitHub Action file ```yaml -jobs: - generateMatrix: - name: "Generate matrix from cabal" - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} - steps: - - name: Checkout base repo - uses: actions/checkout@v2 - - name: Extract the tested GHC versions - id: set-matrix - run: | - wget https://github.com/Kleidukos/get-tested/releases/download/v0.1.5.0/get-tested-0.1.5.0-linux-amd64 -O get-tested - chmod +x get-tested - ./get-tested --ubuntu --macos my-project.cabal >> $GITHUB_OUTPUT - tests: - name: ${{ matrix.ghc }} on ${{ matrix.os }} - needs: generateMatrix - runs-on: ${{ matrix.os }} - strategy: +jobs: + generateMatrix: + name: "Generate matrix from cabal" + runs-on: ubuntu-latest + steps: + - name: Extract the tested GHC versions + uses: turion/get-tested@v0.1.5.0 + tests: + name: ${{ matrix.ghc }} on ${{ matrix.os }} + needs: generateMatrix + runs-on: ${{ matrix.os }} + strategy: matrix: ${{ fromJSON(needs.generateMatrix.outputs.matrix) }} ``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..c6642e3 --- /dev/null +++ b/action.yml @@ -0,0 +1,30 @@ +name: "Generate matrix from cabal" + +inputs: + cabal-file: + description: "The path to your cabal file, e.g. somefolder/myproject.cabal" + required: true + +outputs: + matrix: + description: "The GHC version matrix" + value: ${{ steps.set-matrix.outputs.matrix }} + +runs: + using: "composite" + steps: + - name: Checkout base repo + uses: actions/checkout@v2 + - name: Extract the tested GHC versions + id: set-matrix + shell: bash + run: | + # Extract e.g. 0.1 from /runner/foo/bar/.../v0.1 + export version=$(basename $GITHUB_ACTION_PATH | tail -c +2) + wget https://github.com/Kleidukos/get-tested/releases/download/v${version}/get-tested-${version}-linux-amd64 -O get-tested + chmod +x get-tested + ./get-tested --ubuntu --macos ${{ inputs.cabal-file }} >> $GITHUB_OUTPUT + +branding: + icon: 'list' + color: 'blue'