2023-01-06 08:58:41 +01:00
|
|
|
name: "Setup Golang environment"
|
|
|
|
description: "A reusable workflow that's used to set up the Go environment and cache."
|
|
|
|
inputs:
|
|
|
|
go-version:
|
|
|
|
description: "The version of Golang to set up"
|
|
|
|
required: true
|
2022-12-15 16:23:13 +08:00
|
|
|
|
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
|
|
|
|
steps:
|
2023-01-06 08:58:41 +01:00
|
|
|
- name: setup go ${{ inputs.go-version }}
|
2022-12-15 16:23:13 +08:00
|
|
|
uses: actions/setup-go@v3
|
|
|
|
with:
|
2023-01-06 08:58:41 +01:00
|
|
|
go-version: '${{ inputs.go-version }}'
|
2022-12-15 16:23:13 +08:00
|
|
|
|
|
|
|
- name: go cache
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
# In order:
|
|
|
|
# * Module download cache
|
|
|
|
# * Build cache (Linux)
|
|
|
|
# * Build cache (Mac)
|
|
|
|
# * Build cache (Windows)
|
|
|
|
path: |
|
|
|
|
~/go/pkg/mod
|
|
|
|
~/.cache/go-build
|
|
|
|
~/Library/Caches/go-build
|
|
|
|
~\AppData\Local\go-build
|
2023-01-06 08:58:42 +01:00
|
|
|
key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
|
2022-12-15 16:23:13 +08:00
|
|
|
restore-keys: |
|
2023-01-06 08:58:42 +01:00
|
|
|
${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-
|
2023-01-06 08:58:41 +01:00
|
|
|
${{ runner.os }}-go-${{ inputs.go-version }}-
|
2023-01-06 08:58:40 +01:00
|
|
|
|
|
|
|
- name: set GOPATH
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|