|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: ['pull_request', 'push'] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: Build on ${{ matrix.os }} |
| 8 | + runs-on: ${{ matrix.os }} |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + os: [ubuntu-latest, macOS-latest] |
| 12 | + stack: ["2.1.3"] |
| 13 | + ghc: ["8.8.3"] |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Get the version |
| 17 | + id: get_version |
| 18 | + run: 'echo ::set-output name=version::${GITHUB_REF#refs/tags/}' |
| 19 | + |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + |
| 22 | + |
| 23 | + name: Setup Haskell Stack |
| 24 | + with: |
| 25 | + ghc-version: ${{ matrix.ghc }} |
| 26 | + stack-version: ${{ matrix.stack }} |
| 27 | + |
| 28 | + - uses: actions/cache@v2 |
| 29 | + name: Cache ~/.stack |
| 30 | + with: |
| 31 | + path: ~/.stack |
| 32 | + key: ${{ runner.os }}-${{ matrix.ghc }}-v2 |
| 33 | + |
| 34 | + - name: Add ~/.local/bin to PATH |
| 35 | + run: echo "::add-path::$HOME/.local/bin" |
| 36 | + |
| 37 | + - name: Build |
| 38 | + run: make build |
| 39 | + id: build |
| 40 | + |
| 41 | + - name: Test |
| 42 | + run: make test |
| 43 | + |
| 44 | + - name: Build artifact |
| 45 | + if: startsWith(github.ref, 'refs/tags') |
| 46 | + run: make artifact |
| 47 | + env: |
| 48 | + PATAT_TAG: ${{ steps.get_version.outputs.version }} |
| 49 | + |
| 50 | + - uses: actions/upload-artifact@v2 |
| 51 | + if: startsWith(github.ref, 'refs/tags') |
| 52 | + with: |
| 53 | + path: artifacts/* |
| 54 | + name: artifacts |
| 55 | + |
| 56 | + release: |
| 57 | + name: Release |
| 58 | + needs: build |
| 59 | + runs-on: ubuntu-latest |
| 60 | + if: startsWith(github.ref, 'refs/tags') |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: Get the version |
| 64 | + id: get_version |
| 65 | + run: 'echo ::set-output name=version::${GITHUB_REF#refs/tags/}' |
| 66 | + |
| 67 | + - uses: actions/download-artifact@v2 |
| 68 | + with: |
| 69 | + name: artifacts |
| 70 | + |
| 71 | + - name: Display structure of downloaded files |
| 72 | + run: ls -R |
| 73 | + |
| 74 | + - uses: actions/create-release@v1 |
| 75 | + id: create_release |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + with: |
| 79 | + tag_name: ${{ steps.get_version.outputs.version }} |
| 80 | + release_name: ${{ steps.get_version.outputs.version }} |
| 81 | + |
| 82 | + - name: Upload Linux Asset |
| 83 | + uses: actions/upload-release-asset@v1 |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + with: |
| 87 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 88 | + asset_path: ./stylish-haskell-${{ steps.get_version.outputs.version }}-linux-x86_64.tar.gz |
| 89 | + asset_name: stylish-haskell-${{ steps.get_version.outputs.version }}-linux-x86_64.tar.gz |
| 90 | + asset_content_type: application/gzip |
| 91 | + |
| 92 | + - name: Upload MacOS Asset |
| 93 | + uses: actions/upload-release-asset@v1 |
| 94 | + env: |
| 95 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 96 | + with: |
| 97 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 98 | + asset_path: ./stylish-haskell-${{ steps.get_version.outputs.version }}-darwin-x86_64.zip |
| 99 | + asset_name: stylish-haskell-${{ steps.get_version.outputs.version }}-darwin-x86_64.zip |
| 100 | + asset_content_type: application/zip |
0 commit comments