8
8
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
9
9
branches :
10
10
- main
11
+ # GH caches are removed when not accessed within 7 days - this schedule runs the job every 6 days making
12
+ # sure that we always have some caches on main
13
+ schedule :
14
+ - cron : ' 0 0 */6 * *'
11
15
12
16
jobs :
13
17
build :
69
73
with :
70
74
use-sodium-vrf : true # default is true
71
75
72
- - uses : actions/checkout@v3
76
+ - uses : actions/checkout@v4
73
77
74
78
- name : Cabal update
75
79
run : cabal update
85
89
run : |
86
90
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(.style != "local") | .id' | sort | uniq > dependencies.txt
87
91
92
+ # Use a fresh cache each month
93
+ - name : Store month number as environment variable used in cache version
94
+ run : echo "MONTHNUM=$(/usr/bin/date -u '+%m')" >> $GITHUB_ENV
95
+
88
96
# From the dependency list we restore the cached dependencies.
89
97
# We use the hash of `dependencies.txt` as part of the cache key because that will be stable
90
98
# until the `index-state` values in the `cabal.project` file changes.
@@ -95,7 +103,11 @@ jobs:
95
103
path : |
96
104
${{ steps.setup-haskell.outputs.cabal-store }}
97
105
dist-newstyle
98
- key : cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
106
+ key :
107
+ cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.MONTHNUM }}-${{ hashFiles('dependencies.txt') }}
108
+ # try to restore previous cache from this month if there's no cache for the dependencies set
109
+ restore-keys : |
110
+ cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.MONTHNUM }}-
99
111
100
112
# Now we install the dependencies. If the cache was found and restored in the previous step,
101
113
# this should be a no-op, but if the cache key was not found we need to build stuff so we can
@@ -110,7 +122,8 @@ jobs:
110
122
path : |
111
123
${{ steps.setup-haskell.outputs.cabal-store }}
112
124
dist-newstyle
113
- key : cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
125
+ key :
126
+ cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.MONTHNUM }}-${{ hashFiles('dependencies.txt') }}
114
127
115
128
# Now we build.
116
129
- name : Build all
@@ -140,7 +153,7 @@ jobs:
140
153
done
141
154
142
155
- name : Save Artifact
143
- uses : actions/upload-artifact@v3
156
+ uses : actions/upload-artifact@v4
144
157
with :
145
158
name : artifacts-${{ matrix.sys.os }}-${{ matrix.ghc }}
146
159
path : ./artifacts
@@ -183,7 +196,7 @@ jobs:
183
196
runs-on : ubuntu-latest
184
197
steps :
185
198
- name : Checkout code
186
- uses : actions/checkout@v3
199
+ uses : actions/checkout@v4
187
200
188
201
- name : Create Release Tag
189
202
id : create_release_tag
0 commit comments