4
4
go-version :
5
5
description : " The version of Golang to set up"
6
6
required : true
7
+ key-prefix :
8
+ description : " A prefix to use for the cache key, to separate cache entries from other workflows"
9
+ required : false
10
+ use-build-cache :
11
+ description : " Whether to use the build cache"
12
+ required : false
13
+ # Boolean values aren't supported in the workflow syntax, so we use a
14
+ # string. To not confuse the value with true/false, we use 'yes' and 'no'.
15
+ default : ' yes'
7
16
8
17
runs :
9
18
using : " composite"
@@ -16,19 +25,42 @@ runs:
16
25
git config --global core.autocrlf false
17
26
18
27
- name : setup go ${{ inputs.go-version }}
19
- uses : actions/setup-go@v3
28
+ uses : actions/setup-go@v5
20
29
with :
21
30
go-version : ' ${{ inputs.go-version }}'
22
31
23
- - name : go cache
24
- uses : actions/cache@v3
32
+ - name : go module and build cache
33
+ if : ${{ inputs.use-build-cache == 'yes' }}
34
+ uses : actions/cache@v4
25
35
with :
36
+ # In order:
37
+ # * Module download cache
38
+ # * Build cache (Linux)
39
+ # * Build cache (Mac)
40
+ # * Build cache (Windows)
26
41
path : |
27
- /home/runner/go/pkg/mod
28
- /home/runner/.cache/go-build
29
- key : litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
42
+ ~/go/pkg/mod
43
+ ~/.cache/go-build
44
+ ~/Library/Caches/go-build
45
+ ~\AppData\Local\go-build
46
+ key : ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
30
47
restore-keys : |
31
- litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
32
- litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-
33
- litd-${{ runner.os }}-go-${{ inputs.go-version }}-
34
- litd-${{ runner.os }}-go-
48
+ ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-
49
+ ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-
50
+
51
+ - name : go module cache
52
+ if : ${{ inputs.use-build-cache == 'no' }}
53
+ uses : actions/cache@v4
54
+ with :
55
+ # Just the module download cache.
56
+ path : |
57
+ ~/go/pkg/mod
58
+ key : ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-${{ github.job }}-${{ hashFiles('**/go.sum') }}
59
+ restore-keys : |
60
+ ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-${{ github.job }}-
61
+ ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-
62
+
63
+ - name : set GOPATH
64
+ shell : bash
65
+ run : |
66
+ echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
0 commit comments