mirror of https://github.com/hashicorp/terraform
goenv was making things more complicated than needed since it's really designed to help with interactive use in a shell more than automated use like this. Instead, we'll follow the same strategy that our build.yml was doing of just reading the .go-version file directly and then using the official actions/setup-go action to do the actual installation. The key advantage here is that Go ends up installed in a way where just running "go" will do the right thing, and we no longer need to fuss with shims and version-based path prefixes. Rather than duplicating the logic from build.yml, instead it's factored out into a separate composite action which both build.yml and checks.yml will now share, in case we want to change the Go version selection methodology in the future.pull/30752/head
parent
67fedd48a6
commit
95f26b340b
@ -1,41 +0,0 @@
|
||||
name: 'Set Up Go Toolchain'
|
||||
description: 'Installs the Go toolchain specified in .go-version.'
|
||||
outputs:
|
||||
go-version:
|
||||
description: "Go toolchain version"
|
||||
value: ${{ steps.go.outputs.go-version }}
|
||||
gopath:
|
||||
description: "GOPATH location"
|
||||
value: ${{ steps.go.outputs.gopath }}
|
||||
goenv:
|
||||
description: "Path to the 'goenv' executable"
|
||||
value: ${{ steps.go.outputs.goenv }}
|
||||
goenv-bin-dir:
|
||||
description: "Path to the directory containing the 'goenv' executable"
|
||||
value: ${{ steps.go.outputs.goenv-bin-dir }}
|
||||
go:
|
||||
description: "Path to the 'go' executable"
|
||||
value: ${{ steps.go.outputs.go }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
# We use goenv to make sure we're always using the same Go version we'd
|
||||
# use for releases, as recorded in the .go-version file.
|
||||
- name: "Install Go"
|
||||
id: go
|
||||
shell: bash
|
||||
run: |
|
||||
git clone https://github.com/syndbg/goenv.git ~/.goenv
|
||||
# "install" makes sure we have the .go-version-selected toolchain
|
||||
# available in goenv's repository of toolchains.
|
||||
# (this creates ~/.goenv/versions/VERSION/... to serve as GOROOT)
|
||||
~/.goenv/bin/goenv install
|
||||
# "rehash" generates the wrapper scripts that goenv uses to
|
||||
# select the correct executables for the selected toolchain.
|
||||
# (this is what creates the ~/.goenv/shims/go we refer to below)
|
||||
~/.goenv/bin/goenv rehash
|
||||
echo "::set-output name=go-version::$(~/.goenv/bin/goenv version-name)"
|
||||
echo "::set-output name=gopath::$HOME/go/$(~/.goenv/bin/goenv version-name)"
|
||||
echo "::set-output name=goenv::$HOME/.goenv/bin/goenv"
|
||||
echo "::set-output name=goenv-bin-dir::$HOME/.goenv/bin"
|
||||
echo "::set-output name=go::$HOME/.goenv/shims/go"
|
||||
@ -0,0 +1,23 @@
|
||||
name: 'Determine Go Toolchain Version'
|
||||
description: 'Uses the .go-version file to determine which Go toolchain to use for any Go-related actions downstream.'
|
||||
outputs:
|
||||
version:
|
||||
description: "Go toolchain version"
|
||||
value: ${{ steps.go.outputs.version }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
# We use goenv to make sure we're always using the same Go version we'd
|
||||
# use for releases, as recorded in the .go-version file.
|
||||
- name: "Determine Go version"
|
||||
id: go
|
||||
shell: bash
|
||||
# We use .go-version as our source of truth for current Go
|
||||
# version, because "goenv" can react to it automatically.
|
||||
# However, we don't actually use goenv for our automated
|
||||
# steps in GitHub Actions, because it's primarily for
|
||||
# interactive use in shells and makes things unnecessarily
|
||||
# complex for automation.
|
||||
run: |
|
||||
echo "Building with Go $(cat .go-version)"
|
||||
echo "::set-output name=version::$(cat .go-version)"
|
||||
Loading…
Reference in new issue