From a26a29662ee7eef550a4c1986337cd627aa334ec Mon Sep 17 00:00:00 2001 From: Billy Keyes Date: Wed, 25 Sep 2024 17:07:50 -0700 Subject: [PATCH] Set Actions Go version from go.mod The `.palantir/go-version` file is no longer supported, so always build with the latest patch release of the version specified in `go.mod.` This mostly matches the behavior we're adopting internally, with the main difference being that we'll never build with a newer major version of Go than what is specified in our `go.mod` file. We can't rely on the default behavior of the `setup-go` action because it always downloads the exact version in `go.mod` when a patch version is specified. --- .github/workflows/build.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c43725a5d..ce563745b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,7 @@ jobs: - name: Set Go version id: go_version run: | - GO_VERSION=$(cat .palantir/go-version | sed 's/^go//' ) + GO_VERSION=$(sed -E -n '/^go / s/^go ([0-9]+\.[0-9]+)(\.[0-9]+)?$/\1/p' < go.mod) echo "version=${GO_VERSION}" >> $GITHUB_OUTPUT - name: Set up Go diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 26d521e71..29858c431 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Set Go version id: go_version run: | - GO_VERSION=$(cat .palantir/go-version | sed 's/^go//' ) + GO_VERSION=$(sed -E -n '/^go / s/^go ([0-9]+\.[0-9]+)(\.[0-9]+)?$/\1/p' < go.mod) echo "version=${GO_VERSION}" >> $GITHUB_OUTPUT - name: Set up Go