| 
 | 1 | +name: Hackage  | 
 | 2 | + | 
 | 3 | +on:  | 
 | 4 | +  push:  | 
 | 5 | +    branches:  | 
 | 6 | +      - '*-hackage'  | 
 | 7 | + | 
 | 8 | +jobs:  | 
 | 9 | +  check-and-upload-tarballs:  | 
 | 10 | +    runs-on: ubuntu-latest  | 
 | 11 | +    strategy:  | 
 | 12 | +      matrix:  | 
 | 13 | +        package: ["hie-compat", "hls-graph", "shake-bench",  | 
 | 14 | +                  "hls-plugin-api", "ghcide", "hls-test-utils",  | 
 | 15 | +                  "hls-brittany-plugin", "hls-floskell-plugin", "hls-fourmolu-plugin",  | 
 | 16 | +                  "hls-ormolu-plugin", "hls-stylish-haskell-plugin",  | 
 | 17 | +                  "hls-class-plugin", "hls-eval-plugin", "hls-explicit-imports-plugin",  | 
 | 18 | +                  "hls-haddock-comments-plugin", "hls-hlint-plugin",  | 
 | 19 | +                  "hls-module-name-plugin", "hls-pragmas-plugin",  | 
 | 20 | +                  "hls-refine-imports-plugin", "hls-retrie-plugin",  | 
 | 21 | +                  "hls-splice-plugin", "hls-tactics-plugin",  | 
 | 22 | +                  "hls-call-hierarchy-plugin",  | 
 | 23 | +                  "haskell-language-server"]  | 
 | 24 | +        ghc: ["8.10.7", "8.8.4", "8.6.5"]  | 
 | 25 | + | 
 | 26 | +    steps:  | 
 | 27 | + | 
 | 28 | +      - uses: actions/checkout@v2  | 
 | 29 | +        with:  | 
 | 30 | +          submodules: true  | 
 | 31 | + | 
 | 32 | +      - uses: haskell/actions/setup@v1  | 
 | 33 | +        with:  | 
 | 34 | +          ghc-version: ${{ matrix.ghc }}  | 
 | 35 | +          cabal-version: '3.4'  | 
 | 36 | + | 
 | 37 | +      - name: Cache Cabal  | 
 | 38 | +        uses: actions/cache@v2  | 
 | 39 | +        env:  | 
 | 40 | +          cache-name: cache-cabal  | 
 | 41 | +        with:  | 
 | 42 | +          path: |  | 
 | 43 | +            ~/.cabal/packages  | 
 | 44 | +            ~/.cabal/store  | 
 | 45 | +          key: v2-${{ runner.os }}-${{ matrix.ghc }}-build-${{ hashFiles('cabal.project') }}  | 
 | 46 | +          restore-keys: |  | 
 | 47 | +            v2-${{ runner.os }}-${{ matrix.ghc }}-bench-${{ hashFiles('cabal.project') }}  | 
 | 48 | +            v2-${{ runner.os }}-${{ matrix.ghc }}-build-  | 
 | 49 | +            v2-${{ runner.os }}-${{ matrix.ghc }}  | 
 | 50 | +
  | 
 | 51 | +      - name: "Run cabal check"  | 
 | 52 | +        run: |  | 
 | 53 | +          if [[ ${{ matrix.package }} == *plugin ]]; then  | 
 | 54 | +            cd plugins  | 
 | 55 | +          fi  | 
 | 56 | +          if [[ ${{ matrix.package }} != haskell-language-server ]]; then  | 
 | 57 | +            cd ${{ matrix.package }}  | 
 | 58 | +          fi  | 
 | 59 | +          cabal check  | 
 | 60 | +
  | 
 | 61 | +      - name: "Generate package dist tarball"  | 
 | 62 | +        id: generate-dist-tarball  | 
 | 63 | +        run: |  | 
 | 64 | +          if [[ ${{ matrix.package }} == haskell-language-server ]]; then  | 
 | 65 | +            cabal sdist --builddir=./  | 
 | 66 | +          else  | 
 | 67 | +            cabal sdist ${{ matrix.package }} --builddir=./  | 
 | 68 | +          fi  | 
 | 69 | +          echo ::set-output name=path::$(ls ./sdist/${{ matrix.package }}-*)  | 
 | 70 | +
  | 
 | 71 | +      - name: "Unpack package source in an isolated location"  | 
 | 72 | +        run: cabal unpack ${{ steps.generate-dist-tarball.outputs.path }} --destdir=./incoming  | 
 | 73 | + | 
 | 74 | +      - name: "Try to get the current hackage version"  | 
 | 75 | +        id: get-hackage-version  | 
 | 76 | +        run: |  | 
 | 77 | +          cd ./incoming  | 
 | 78 | +          if cabal get $(ls -d ${{ matrix.package }}-*) --destdir=../current; then  | 
 | 79 | +            echo ::set-output name=exists::true  | 
 | 80 | +          fi  | 
 | 81 | +
  | 
 | 82 | +      - name: "Compare the incoming and the current hackage version of the package"  | 
 | 83 | +        id: compare-current-version  | 
 | 84 | +        if: steps.get-hackage-version.exists == 'true'  | 
 | 85 | +        run: |  | 
 | 86 | +          # This will throw an error if there is any difference cause we have to bump up the package version  | 
 | 87 | +          diff -qr -x "*.md" -x "data" $(ls -d ./incoming/${{ matrix.package }}-*) $(ls -d ./current/${{ matrix.package }}-*)  | 
 | 88 | +
  | 
 | 89 | +      - name: "Create appropiate cabal.project"  | 
 | 90 | +        if: steps.get-hackage-version.exists != 'true'  | 
 | 91 | +        run: |  | 
 | 92 | +          cd $(ls -d ./incoming/${{ matrix.package }}-*)  | 
 | 93 | +          echo "packages: . ../../* ../../plugins/*" > cabal.project  | 
 | 94 | +          # TODO: remove when not needed  | 
 | 95 | +          echo "allow-newer: Chart-diagrams:diagrams-core, SVGFonts:diagrams-core" >> cabal.project  | 
 | 96 | +
  | 
 | 97 | +      - name: "Build all package components in isolation"  | 
 | 98 | +        if: steps.get-hackage-version.exists != 'true'  | 
 | 99 | +        run: |  | 
 | 100 | +          cd $(ls -d ./incoming/${{ matrix.package }}-*)  | 
 | 101 | +          cabal build --enable-tests --enable-benchmarks  | 
 | 102 | +
  | 
 | 103 | +      - name: "Generate haddock for hackage"  | 
 | 104 | +        if: steps.get-hackage-version.exists != 'true'  | 
 | 105 | +        run: |  | 
 | 106 | +          cd $(ls -d ./incoming/${{ matrix.package }}-*)  | 
 | 107 | +          cabal haddock --haddock-for-hackage  | 
 | 108 | +
  | 
 | 109 | +      - name: "Upload package dist tarball"  | 
 | 110 | +        if: steps.get-hackage-version.exists != 'true'  | 
 | 111 | +        uses: actions/upload-artifact@v2  | 
 | 112 | +        with:  | 
 | 113 | +          name: ${{ matrix.package }}  | 
 | 114 | +          path: ${{ steps.generate-dist-tarball.outputs.path }}  | 
 | 115 | + | 
 | 116 | +  upload-candidate:  | 
 | 117 | +    needs: check-and-upload-tarballs  | 
 | 118 | +    runs-on: ubuntu-latest  | 
 | 119 | +    steps:  | 
 | 120 | + | 
 | 121 | +      - uses: actions/download-artifact@v2  | 
 | 122 | +        with:  | 
 | 123 | +          path: packages  | 
 | 124 | + | 
 | 125 | +      - name: "Join all tarballs"  | 
 | 126 | +        run: find ./packages -type f -name '*.tar.gz' -exec cp {} ./packages \;  | 
 | 127 | + | 
 | 128 | +      - name: "Upload all tarballs to hackage"  | 
 | 129 | +        uses: haskell-actions/hackage-publish@v1  | 
 | 130 | +        with:  | 
 | 131 | +          hackageToken: ${{ secrets.HACKAGE_AUTH_TOKEN }}  | 
 | 132 | +          packagesPath: packages  | 
 | 133 | +          publish: false  | 
0 commit comments