@@ -16,29 +16,49 @@ jobs:
1616 runs-on : ubuntu-latest
1717 steps :
1818 - uses : actions/checkout@v4
19- - uses : actions/setup-haskell@v1
19+
20+ - name : Set up GHC ${{ matrix.ghc-version }}
21+ uses : haskell-actions/setup@v2
22+ id : setup
2023 with :
2124 ghc-version : ' 9.10.1'
22- cabal-version : ' 3.12.1.0'
23- - name : Cache
24- uses : actions/cache@v3
25+
26+ - name : Configure the build
27+ run : |
28+ cabal configure
29+ cabal build all --dry-run
30+
31+ - name : Restore cached dependencies
32+ uses : actions/cache/restore@v4
33+ id : cache
2534 env :
26- cache-name : cache- cabal
35+ key : ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}- cabal-${{ steps.setup.outputs.cabal-version }}
2736 with :
28- path : ~/.cabal
29- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
30- restore-keys : |
31- ${{ runner.os }}-build-${{ env.cache-name }}-
32- ${{ runner.os }}-build-
33- ${{ runner.os }}-
37+ path : ${{ steps.setup.outputs.cabal-store }}
38+ key : ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
39+ restore-keys : ${{ env.key }}-
40+
3441 - name : Install dependencies
35- run : |
36- cabal update
37- cabal build --only-dependencies
42+ # If we had an exact cache hit, the dependencies will be up to date.
43+ if : steps.cache.outputs.cache-hit != 'true'
44+ run : cabal build all --only-dependencies
45+
46+ # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
47+ - name : Save cached dependencies
48+ uses : actions/cache/save@v4
49+ # If we had an exact cache hit, trying to save the cache would error because of key clash.
50+ if : steps.cache.outputs.cache-hit != 'true'
51+ with :
52+ path : ${{ steps.setup.outputs.cabal-store }}
53+ key : ${{ steps.cache.outputs.cache-primary-key }}
54+
3855 - name : Build hakyll project
3956 run : cabal build
57+
4058 - name : Build static website
4159 run : cabal exec site build
60+
61+ # upload-pages-artifact defaults to uploading the _site directory
4262 - name : Upload artifact
4363 uses : actions/upload-pages-artifact@v3
4464
0 commit comments