2024-01-08 22:18:41 +00:00
|
|
|
name: get-go-version
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
2024-07-05 19:19:23 +00:00
|
|
|
inputs:
|
|
|
|
ref:
|
|
|
|
description: |
|
|
|
|
The Consul ref/branch (e.g. release/1.18.x) for which to determine the Go version.
|
|
|
|
If not provided, the default actions/checkout value (current ref) is used.
|
|
|
|
type: string
|
2024-01-08 22:18:41 +00:00
|
|
|
outputs:
|
|
|
|
go-version:
|
|
|
|
description: "The Go version detected by this workflow"
|
|
|
|
value: ${{ jobs.get-go-version.outputs.go-version }}
|
2024-01-12 14:57:38 +00:00
|
|
|
go-version-previous:
|
|
|
|
description: "The Go version (MAJOR.MINOR) prior to the current one, used for backwards compatibility testing"
|
|
|
|
value: ${{ jobs.get-go-version.outputs.go-version-previous }}
|
2024-01-08 22:18:41 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
get-go-version:
|
|
|
|
name: "Determine Go toolchain version"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
go-version: ${{ steps.get-go-version.outputs.go-version }}
|
2024-01-12 14:57:38 +00:00
|
|
|
go-version-previous: ${{ steps.get-go-version.outputs.go-version-previous }}
|
2024-01-08 22:18:41 +00:00
|
|
|
steps:
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
2024-07-05 19:19:23 +00:00
|
|
|
with:
|
|
|
|
# If not set, will default to current branch.
|
|
|
|
ref: ${{ inputs.ref }}
|
2024-01-08 22:18:41 +00:00
|
|
|
- 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
|
2024-01-12 14:57:38 +00:00
|
|
|
GO_MINOR_VERSION=${GO_VERSION%.*}
|
|
|
|
GO_VERSION_PREVIOUS="${GO_MINOR_VERSION%.*}.$((${GO_MINOR_VERSION#*.}-1))"
|
|
|
|
echo "Previous version ${GO_VERSION_PREVIOUS}"
|
|
|
|
echo "go-version-previous=${GO_VERSION_PREVIOUS}" >> $GITHUB_OUTPUT
|