mirror of
https://github.com/status-im/consul.git
synced 2025-02-06 02:44:01 +00:00
3b111277ad
ci: Set Go version consistently via .go-version Ensure Go version is determined consistently for CI and Docker builds rather than spread across several different files. The intent is to eventually replace this with use of the `toolchain` directive in Go 1.21.
35 lines
1.3 KiB
YAML
35 lines
1.3 KiB
YAML
name: get-go-version
|
|
|
|
on:
|
|
workflow_call:
|
|
outputs:
|
|
go-version:
|
|
description: "The Go version detected by this workflow"
|
|
value: ${{ jobs.get-go-version.outputs.go-version }}
|
|
|
|
jobs:
|
|
get-go-version:
|
|
name: "Determine Go toolchain version"
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
go-version: ${{ steps.get-go-version.outputs.go-version }}
|
|
steps:
|
|
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
|
- name: Determine Go version
|
|
id: get-go-version
|
|
# We use .go-version as our source of truth for current Go
|
|
# version, because "goenv" can react to it automatically.
|
|
#
|
|
# In the future, we can transition from .go-version and goenv to
|
|
# Go 1.21 `toolchain` directives by updating this workflow rather
|
|
# than individually setting `go-version-file` in each `setup-go`
|
|
# job (as of 2024-01-03, `setup-go` does not support `toolchain`).
|
|
#
|
|
# When changing the method of Go version detection, also update
|
|
# GOLANG_VERSION detection in the root Makefile; this is used for
|
|
# setting the Dockerfile Go version.
|
|
run: |
|
|
GO_VERSION=$(head -n 1 .go-version)
|
|
echo "Building with Go ${GO_VERSION}"
|
|
echo "go-version=${GO_VERSION}" >> $GITHUB_OUTPUT
|