Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use top level VERSION file when it exists #3309

Merged
merged 2 commits into from
Sep 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions go/private/sdk.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ def _detect_sdk_platform(ctx, goroot):
return platforms[0]

def _detect_sdk_version(ctx, goroot):
version_file_path = goroot + "/VERSION"
if ctx.path(version_file_path).exists:
version_contents = ctx.read(version_file_path)

# VERSION file has version prefixed by go, eg. go1.18.3
return version_contents[2:]

# The top-level VERSION file does not exist in all Go SDK distributions, e.g. those shipped by Debian or Fedora.
# Falling back to running "go version"
go_binary_path = goroot + "/bin/go"
result = ctx.execute([go_binary_path, "version"])
if result.return_code != 0:
Expand Down