-
Notifications
You must be signed in to change notification settings - Fork 326
30 lines (28 loc) · 1.11 KB
/
reusable-get-go-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- 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`).
run: |
GO_VERSION=$(head -n 1 .go-version)
echo "Building with Go ${GO_VERSION}"
echo "go-version=${GO_VERSION}" >> $GITHUB_OUTPUT