CI: Query latest version in scripts/dist/install-go.sh
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
25fb0e0fc1
commit
f77f46b180
1 changed files with 21 additions and 16 deletions
37
scripts/dist/install-go.sh
vendored
37
scripts/dist/install-go.sh
vendored
|
@ -1,23 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Installs Go on Linux
|
||||
# Installs latest Go on Linux
|
||||
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go.sh)
|
||||
|
||||
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"
|
||||
|
||||
GOLANG_VERSION=1.18.4
|
||||
DESTDIR=$(realpath "${1:-/usr/local}")
|
||||
|
||||
# abort if not executed as root
|
||||
# Abort if not executed as root.
|
||||
if [[ $(id -u) != "0" ]]; then
|
||||
echo "Usage: run ${0##*/} as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing Go in \"$DESTDIR\"..."
|
||||
# Query version.
|
||||
if [[ -z $GOLANG_VERSION ]]; then
|
||||
GOLANG_VERSION=$(curl -fsSL https://go.dev/VERSION?m=text)
|
||||
fi
|
||||
|
||||
echo "Installing ${GOLANG_VERSION} in \"${DESTDIR}\"..."
|
||||
|
||||
set -e
|
||||
|
||||
# Query architecture.
|
||||
if [[ $PHOTOPRISM_ARCH ]]; then
|
||||
SYSTEM_ARCH=$PHOTOPRISM_ARCH
|
||||
else
|
||||
|
@ -32,18 +37,15 @@ set -eux;
|
|||
|
||||
case $DESTARCH in
|
||||
amd64 | AMD64 | x86_64 | x86-64)
|
||||
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"
|
||||
CHECKSUM="c9b099b68d93f5c5c8a8844a89f8db07eaa58270e3a1e01804f17f4cf8df02f5 *go.tgz"
|
||||
URL="https://go.dev/dl/${GOLANG_VERSION}.linux-amd64.tar.gz"
|
||||
;;
|
||||
|
||||
arm64 | ARM64 | aarch64)
|
||||
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"
|
||||
CHECKSUM="35014d92b50d97da41dade965df7ebeb9a715da600206aa59ce1b2d05527421f *go.tgz"
|
||||
URL="https://go.dev/dl/${GOLANG_VERSION}.linux-arm64.tar.gz"
|
||||
;;
|
||||
|
||||
arm | ARM | aarch | armv7l | armhf)
|
||||
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz"
|
||||
CHECKSUM="7dfeab572e49638b0f3d9901457f0622c27b73301c2b99db9f5e9568ff40460c *go.tgz"
|
||||
URL="https://go.dev/dl/${GOLANG_VERSION}.linux-armv6l.tar.gz"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
@ -52,14 +54,17 @@ case $DESTARCH in
|
|||
;;
|
||||
esac
|
||||
|
||||
echo "Downloading Go from \"$URL\". Please wait."
|
||||
echo "Installing Go from \"$URL\". Please wait."
|
||||
|
||||
wget -O go.tgz $URL
|
||||
echo "$CHECKSUM" | sha256sum -c -
|
||||
# Replace current installation in "/usr/local/go".
|
||||
rm -rf /usr/local/go
|
||||
tar -C /usr/local -xzf go.tgz
|
||||
rm go.tgz
|
||||
wget -c https://go.dev/dl/go1.18.4.linux-amd64.tar.gz -O - | tar -xz -C /usr/local
|
||||
|
||||
/usr/local/go/bin/go version
|
||||
# Add symlink to go binary.
|
||||
ln -sf /usr/local/go/bin/go /usr/local/bin/go
|
||||
ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt
|
||||
|
||||
# Test if it works.
|
||||
go version
|
||||
|
||||
echo "Done."
|
Loading…
Reference in a new issue