|
| 1 | +name: RELEASE |
| 2 | + |
| 3 | +on: |
| 4 | + # Trigger the workflow on the new 'v*' tag created |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v*" |
| 8 | + |
| 9 | +jobs: |
| 10 | + create_release: |
| 11 | + name: Create Github Release |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Check out code |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Create Release |
| 18 | + id: create_release |
| 19 | + uses: actions/create-release@v1 |
| 20 | + env: |
| 21 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + with: |
| 23 | + tag_name: ${{ github.ref }} |
| 24 | + release_name: Release ${{ github.ref }} |
| 25 | + draft: true |
| 26 | + prerelease: false |
| 27 | + |
| 28 | + - name: Output Release URL File |
| 29 | + run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt |
| 30 | + - name: Save Release URL File for publish |
| 31 | + uses: actions/upload-artifact@v2 |
| 32 | + with: |
| 33 | + name: release_url |
| 34 | + path: release_url.txt |
| 35 | + |
| 36 | + build_artifact: |
| 37 | + needs: [create_release] |
| 38 | + name: ${{ matrix.os }}/GHC ${{ matrix.ghc }}/${{ github.ref }} |
| 39 | + runs-on: ${{ matrix.os }} |
| 40 | + strategy: |
| 41 | + matrix: |
| 42 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 43 | + ghc: |
| 44 | + - "8.10" |
| 45 | + cabal: [latest] |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Check out code |
| 49 | + |
| 50 | + |
| 51 | + - name: Set tag name |
| 52 | + uses: olegtarasov/[email protected] |
| 53 | + id: tag |
| 54 | + with: |
| 55 | + tagRegex: "v(.*)" |
| 56 | + |
| 57 | + - name: Setup Haskell |
| 58 | + uses: haskell/actions/setup@v1 |
| 59 | + id: setup-haskell-cabal |
| 60 | + with: |
| 61 | + ghc-version: ${{ matrix.ghc }} |
| 62 | + cabal-version: ${{ matrix.cabal }} |
| 63 | + |
| 64 | + - name: Freeze |
| 65 | + run: | |
| 66 | + cabal freeze |
| 67 | +
|
| 68 | + - name: Cache ~/.cabal/store |
| 69 | + uses: actions/cache@v2 |
| 70 | + with: |
| 71 | + path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} |
| 72 | + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} |
| 73 | + |
| 74 | + - if: matrix.os == 'windows-latest' |
| 75 | + name: Set extension to .exe on Windows |
| 76 | + run: echo "EXT=.exe" >> $env:GITHUB_ENV |
| 77 | + |
| 78 | + - name: Build binary |
| 79 | + run: | |
| 80 | + mkdir -p dist/pebble-${{ steps.tag.outputs.tag }}-${{ runner.os }} |
| 81 | + cabal install exe:haskell-pebble-exe --install-method=copy --overwrite-policy=always --installdir=dist |
| 82 | + mv ./dist/haskell-pebble-exe${{ env.EXT }} ./dist/pebble-${{ steps.tag.outputs.tag }}-${{ runner.os }}/pebble${{ env.EXT }} |
| 83 | +
|
| 84 | + - name: Compress binary |
| 85 | + |
| 86 | + with: |
| 87 | + file: ./dist/pebble-${{ steps.tag.outputs.tag }}-${{ runner.os }}/pebble${{ env.EXT }} |
| 88 | + |
| 89 | + - name: zip it |
| 90 | + uses: thedoctor0/zip-release@master |
| 91 | + with: |
| 92 | + type: 'tar' |
| 93 | + directory: ./dist |
| 94 | + path: pebble-${{ steps.tag.outputs.tag }}-${{ runner.os }}/pebble${{ env.EXT }} |
| 95 | + filename: pebble-${{ steps.tag.outputs.tag }}-${{ runner.os }}.tar.gz |
| 96 | + |
| 97 | + - name: Load Release URL File from release job |
| 98 | + uses: actions/download-artifact@v2 |
| 99 | + with: |
| 100 | + name: release_url |
| 101 | + |
| 102 | + - name: Downdload Release File Name & Upload URL |
| 103 | + uses: actions/download-artifact@v2 |
| 104 | + with: |
| 105 | + name: release_url |
| 106 | + |
| 107 | + - name: Get Release File Name & Upload URL |
| 108 | + id: get_release_info |
| 109 | + run: | |
| 110 | + echo "::set-output name=upload_url::$(cat release_url.txt)" |
| 111 | +
|
| 112 | + - name: Upload Release Asset |
| 113 | + id: upload-release-asset |
| 114 | + uses: actions/upload-release-asset@v1 |
| 115 | + env: |
| 116 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + with: |
| 118 | + upload_url: ${{ steps.get_release_info.outputs.upload_url }} |
| 119 | + asset_path: ./dist/pebble-${{ steps.tag.outputs.tag }}-${{ runner.os }}.tar.gz |
| 120 | + asset_name: pebble-${{ steps.tag.outputs.tag }}-${{ runner.os }}.tar.gz |
| 121 | + asset_content_type: application/gzip |
0 commit comments