Merge commit '08e062efb44cbf8230a1766b15190f25bef8fb99' into debian
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
language: bash
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: focal # 20.04
|
||||
- os: linux
|
||||
dist: bionic # 18.04 (EOL @ April 2023)
|
||||
- os: osx
|
||||
osx_image: xcode12.5 # 11.3
|
||||
- os: osx
|
||||
osx_image: xcode12.2 # 10.15.7
|
||||
|
||||
|
||||
install: true
|
||||
env: REQVER=1.16.7
|
||||
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
- fish
|
||||
update: true
|
||||
apt:
|
||||
packages:
|
||||
- fish
|
||||
update: true
|
||||
|
||||
script: >-
|
||||
bash tests/install.sh &&
|
||||
source ~/.bashrc &&
|
||||
bash tests/validate.sh &&
|
||||
bash tests/remove.sh
|
||||
|
||||
bash tests/install-custom-version.sh &&
|
||||
source ~/.bashrc &&
|
||||
bash tests/custom-version-validate.sh &&
|
||||
bash tests/remove.sh
|
||||
|
||||
SHELL=$(which fish) bash tests/install.sh
|
||||
@@ -6,8 +6,11 @@ Feel free to change the variables on the beginning to match whatever version of
|
||||
|
||||
Tested working on:
|
||||
|
||||
* :white_check_mark: Ubuntu 16.04 to 20.04
|
||||
* :white_check_mark: macOS Sierra (10.12) to Big Sur (11.3)
|
||||
* :white_check_mark: Ubuntu
|
||||
* ⚠️ macOS, generally [^1]
|
||||
* :white_check_mark: Fedora (Workstation)
|
||||
|
||||
[^1]: I no longer have the ability to perform automated testing for free. Testers are welcome!
|
||||
|
||||
Supported shells:
|
||||
* Bash, fish, Zsh
|
||||
|
||||
@@ -2,11 +2,30 @@
|
||||
# shellcheck disable=SC2016
|
||||
set -e
|
||||
|
||||
VERSION="1.20.6"
|
||||
FALLBACK_VERSION="1.24.4"
|
||||
VERSION="$FALLBACK_VERSION"
|
||||
|
||||
[ -z "$GOROOT" ] && GOROOT="$HOME/.go"
|
||||
[ -z "$GOPATH" ] && GOPATH="$HOME/go"
|
||||
|
||||
# Function to detect the latest Go version from go.dev
|
||||
get_latest_version() {
|
||||
local latest_version=""
|
||||
|
||||
if hash wget 2>/dev/null; then
|
||||
latest_version=$(wget -qO- "https://go.dev/VERSION?m=text" 2>/dev/null | head -n 1 | sed 's/go//')
|
||||
elif hash curl 2>/dev/null; then
|
||||
latest_version=$(curl -sL "https://go.dev/VERSION?m=text" 2>/dev/null | head -n 1 | sed 's/go//')
|
||||
fi
|
||||
|
||||
# Validate version format
|
||||
if [[ "$latest_version" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
|
||||
echo "$latest_version"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
OS="$(uname -s)"
|
||||
ARCH="$(uname -m)"
|
||||
|
||||
@@ -117,6 +136,18 @@ elif [ ! -z "$1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Auto-detect latest version if --version was not specified
|
||||
if [ "$VERSION" == "$FALLBACK_VERSION" ]; then
|
||||
echo "Detecting latest Go version..."
|
||||
DETECTED_VERSION=$(get_latest_version)
|
||||
if [ -n "$DETECTED_VERSION" ]; then
|
||||
VERSION="$DETECTED_VERSION"
|
||||
echo "Latest version detected: $VERSION"
|
||||
else
|
||||
echo "Could not detect latest version, using fallback: $VERSION"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "$GOROOT" ]; then
|
||||
echo "The Go install directory ($GOROOT) already exists. Exiting."
|
||||
exit 1
|
||||
@@ -127,9 +158,9 @@ TEMP_DIRECTORY=$(mktemp -d)
|
||||
|
||||
echo "Downloading $PACKAGE_NAME ..."
|
||||
if hash wget 2>/dev/null; then
|
||||
wget https://storage.googleapis.com/golang/$PACKAGE_NAME -O "$TEMP_DIRECTORY/go.tar.gz"
|
||||
wget https://dl.google.com/go/$PACKAGE_NAME -O "$TEMP_DIRECTORY/go.tar.gz"
|
||||
else
|
||||
curl -o "$TEMP_DIRECTORY/go.tar.gz" https://storage.googleapis.com/golang/$PACKAGE_NAME
|
||||
curl -o "$TEMP_DIRECTORY/go.tar.gz" https://dl.google.com/go/$PACKAGE_NAME
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user