-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify go version maintenance (#2977)
- Loading branch information
Showing
24 changed files
with
141 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This action sets GO_VERSION from the project's go.mod. | ||
# | ||
# Must be run after actions/checkout to ensure go.mod is available to | ||
# source the project's go version from. | ||
|
||
name: 'Set GO_VERSION env var from go.mod' | ||
description: 'Read the go version from go.mod and add it as env var GO_VERSION in the github env' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Set the project Go version in the environment | ||
# A script works across different platforms but attempting to replicate the script directly in | ||
# the run statement runs into platform-specific path handling issues. | ||
run: .github/actions/set-go-version-in-env/go_version_env.sh >> $GITHUB_ENV | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Prints the go version defined in the repo's go.mod. This is useful | ||
# for configuring the correct version of go to install in CI. | ||
# | ||
# `go list -m -f '{{.GoVersion}}'` should be preferred outside of CI | ||
# when go is already installed. | ||
|
||
# 3 directories above this script | ||
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd ../../.. && pwd ) | ||
|
||
echo GO_VERSION="~$(sed -n -e 's/^go //p' "${AVALANCHE_PATH}"/go.mod)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This action targets setup-go@v3 to support workers with old NodeJS | ||
# incompabible with newer versions of setup-go. | ||
# | ||
# Since github actions do not support dynamically configuring the | ||
# versions in a uses statement (e.g. `actions/setup-go@${{ var }}`) it | ||
# is necessary to define an action per version rather than one action | ||
# that can be parameterized. | ||
# | ||
# Must be run after actions/checkout to ensure go.mod is available to | ||
# source the project's go version from. | ||
|
||
name: 'Install Go toolchain with project defaults' | ||
description: 'Install a go toolchain with project defaults' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Set the project Go version in the environment | ||
uses: ./.github/actions/set-go-version-in-env | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '${{ env.GO_VERSION }}' | ||
check-latest: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This action targets the project default version of setup-go. For | ||
# workers with old NodeJS incompabible with newer versions of | ||
# setup-go, try setup-go-for-project-v3. | ||
# | ||
# Since github actions do not support dynamically configuring the | ||
# versions in a uses statement (e.g. `actions/setup-go@${{ var }}`) it | ||
# is necessary to define an action per version rather than one action | ||
# that can be parameterized. | ||
# | ||
# Must be run after actions/checkout to ensure go.mod is available to | ||
# source the project's go version from. | ||
|
||
name: 'Install Go toolchain with project defaults' | ||
description: 'Install a go toolchain with project defaults' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Set the project Go version in the environment | ||
uses: ./.github/actions/set-go-version-in-env | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '${{ env.GO_VERSION }}' | ||
check-latest: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.