|
| 1 | +name: cabal-install |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + cache: |
| 7 | + description: cache key version |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +defaults: |
| 12 | + run: |
| 13 | + shell: bash |
| 14 | + |
| 15 | +jobs: |
| 16 | + cabal-install: |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + os: |
| 20 | + - ubuntu-latest |
| 21 | + - macos-latest |
| 22 | + - windows-latest |
| 23 | + |
| 24 | + runs-on: |
| 25 | + - ${{ matrix.os }} |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Set os specific values |
| 32 | + id: os |
| 33 | + run: | |
| 34 | + case ${{ runner.os }} in |
| 35 | + "Windows") |
| 36 | + ext=.exe |
| 37 | + echo "store=C:sr" >> $GITHUB_OUTPUT |
| 38 | + echo "ext=${ext}" >> $GITHUB_OUTPUT |
| 39 | + ;; |
| 40 | + *) |
| 41 | + ext= |
| 42 | + echo "store=${HOME}/.cabal" >> $GITHUB_OUTPUT |
| 43 | + echo "ext=${ext}" >> $GITHUB_OUTPUT |
| 44 | + ;; |
| 45 | + esac |
| 46 | +
|
| 47 | + exename=hpc-codecov-${{ runner.os }}${ext} |
| 48 | + echo "exename=${exename}" >> $GITHUB_OUTPUT |
| 49 | + echo "path=bin/${exename}" >> $GITHUB_OUTPUT |
| 50 | +
|
| 51 | + - name: Cache cabal store directory |
| 52 | + uses: actions/cache@v4 |
| 53 | + with: |
| 54 | + path: ${{ steps.os.outputs.store }} |
| 55 | + key: cabal-store-${{ env.cache-version }} |
| 56 | + |
| 57 | + - name: Cache ghc under macOS |
| 58 | + if: runner.os == 'macos' |
| 59 | + uses: actions/cache@v4 |
| 60 | + with: |
| 61 | + path: ~/.ghcup |
| 62 | + key: ghcup-${{ runner.os }}-${{ env.cache-version }} |
| 63 | + |
| 64 | + - name: Setup ghc and cabal-install |
| 65 | + uses: haskell-actions/setup@v2 |
| 66 | + |
| 67 | + - name: Configure |
| 68 | + run: cabal configure -O2 --enable-executable-stripping |
| 69 | + |
| 70 | + - name: Install to current directory |
| 71 | + run: | |
| 72 | + mkdir -v ./bin |
| 73 | + cabal install --install-method=copy --installdir=./bin |
| 74 | + mv -v bin/hpc-codecov${{ steps.os.outputs.ext }} ${{ steps.os.outputs.path }} |
| 75 | + ls -lh ${{ steps.os.outputs.path }} |
| 76 | +
|
| 77 | + - name: Strip executable |
| 78 | + if: runner.os != 'macos' |
| 79 | + run: strip -s ${{ steps.os.outputs.path }} |
| 80 | + |
| 81 | + - name: Compress executable |
| 82 | + if: runner.os != 'macos' |
| 83 | + uses: svenstaro/upx-action@v2 |
| 84 | + with: |
| 85 | + files: ${{ steps.os.outputs.path }} |
| 86 | + args: -9 |
| 87 | + strip: false |
| 88 | + |
| 89 | + - name: Upload artifact |
| 90 | + uses: actions/upload-artifact@v4 |
| 91 | + with: |
| 92 | + name: ${{ steps.os.outputs.exename }} |
| 93 | + path: ${{ steps.os.outputs.path }} |
0 commit comments