CI: Improve dist install scripts and add usage docs

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2022-07-23 13:55:05 +02:00
parent ee0ca41a53
commit 25fb0e0fc1
9 changed files with 148 additions and 72 deletions

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env bash
# Installs Go Tools on Linux
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go-tools.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:/usr/local/go/bin:/go/bin:$PATH"
# abort if not executed as root
@@ -13,7 +16,12 @@ if [[ -z "$GOPATH" ]] || [[ -z "$GOBIN" ]]; then
exit 1
fi
SYSTEM_ARCH=$("$(dirname "$0")/arch.sh")
if [[ $PHOTOPRISM_ARCH ]]; then
SYSTEM_ARCH=$PHOTOPRISM_ARCH
else
SYSTEM_ARCH=$(uname -m)
fi
DESTARCH=${2:-$SYSTEM_ARCH}
echo "Installing Go Tools for ${DESTARCH^^}..."
@@ -24,16 +32,22 @@ mkdir -p "$GOPATH/src" "$GOBIN"
go install github.com/tianon/gosu@latest
# no additional tools on ARMv7 to reduce build time
if [[ $DESTARCH != "arm" ]]; then
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/psampaz/go-mod-outdated@latest
go install github.com/dsoprea/go-exif/v3/command/exif-read-tool@latest
go install github.com/mikefarah/yq/v4@latest
case $DESTARCH in
arm | ARM | aarch | armv7l | armhf)
# no additional tools on ARMv7 to reduce build time
echo "Skipping installation of goimports, go-mod-outdated, exif-read-tool and richgo."
;;
go install github.com/kyoh86/richgo@latest
cp "$GOBIN/richgo" /usr/local/bin/richgo
fi
*)
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/psampaz/go-mod-outdated@latest
go install github.com/dsoprea/go-exif/v3/command/exif-read-tool@latest
go install github.com/mikefarah/yq/v4@latest
go install github.com/kyoh86/richgo@latest
cp "$GOBIN/richgo" /usr/local/bin/richgo
;;
esac
chmod -R a+rwX "$GOPATH"