2021-02-24 00:26:48 +00:00
|
|
|
#!/bin/bash
|
2019-02-10 12:16:29 +00:00
|
|
|
|
2022-11-04 02:41:26 +00:00
|
|
|
COMPILER_CONTAINER="stashapp/compiler:7"
|
2021-02-03 22:41:43 +00:00
|
|
|
|
2020-06-29 04:44:21 +00:00
|
|
|
BUILD_DATE=`go run -mod=vendor scripts/getDate.go`
|
2019-10-23 10:52:06 +00:00
|
|
|
GITHASH=`git rev-parse --short HEAD`
|
2020-02-06 19:39:08 +00:00
|
|
|
STASH_VERSION=`git describe --tags --exclude latest_develop`
|
2021-02-03 22:41:43 +00:00
|
|
|
|
2020-06-29 04:44:21 +00:00
|
|
|
SETENV="BUILD_DATE=\"$BUILD_DATE\" GITHASH=$GITHASH STASH_VERSION=\"$STASH_VERSION\""
|
2021-09-22 03:08:34 +00:00
|
|
|
SETUP="export CGO_ENABLED=1;"
|
2021-05-16 09:19:56 +00:00
|
|
|
WINDOWS="echo '=== Building Windows binary ==='; $SETENV make cross-compile-windows;"
|
2022-02-03 00:20:34 +00:00
|
|
|
DARWIN="echo '=== Building OSX binary ==='; $SETENV make cross-compile-macos-intel;"
|
|
|
|
DARWIN_ARM64="echo '=== Building OSX (arm64) binary ==='; $SETENV make cross-compile-macos-applesilicon;"
|
2021-05-16 09:19:56 +00:00
|
|
|
LINUX_AMD64="echo '=== Building Linux (amd64) binary ==='; $SETENV make cross-compile-linux;"
|
|
|
|
LINUX_ARM64v8="echo '=== Building Linux (armv8/arm64) binary ==='; $SETENV make cross-compile-linux-arm64v8;"
|
|
|
|
LINUX_ARM32v7="echo '=== Building Linux (armv7/armhf) binary ==='; $SETENV make cross-compile-linux-arm32v7;"
|
|
|
|
LINUX_ARM32v6="echo '=== Building Linux (armv6 | Raspberry Pi 1) binary ==='; $SETENV make cross-compile-pi;"
|
2021-02-03 22:41:43 +00:00
|
|
|
BUILD_COMPLETE="echo '=== Build complete ==='"
|
|
|
|
|
|
|
|
BUILD=`echo "$1" | cut -d - -f 1`
|
|
|
|
if [ "$BUILD" == "windows" ]
|
|
|
|
then
|
|
|
|
echo "Building Windows"
|
|
|
|
COMMAND="$SETUP $WINDOWS $BUILD_COMPLETE"
|
|
|
|
elif [ "$BUILD" == "darwin" ]
|
|
|
|
then
|
|
|
|
echo "Building Darwin(MacOSX)"
|
|
|
|
COMMAND="$SETUP $DARWIN $BUILD_COMPLETE"
|
|
|
|
elif [ "$BUILD" == "amd64" ]
|
|
|
|
then
|
|
|
|
echo "Building Linux AMD64"
|
|
|
|
COMMAND="$SETUP $LINUX_AMD64 $BUILD_COMPLETE"
|
|
|
|
elif [ "$BUILD" == "arm64v8" ]
|
|
|
|
then
|
|
|
|
echo "Building Linux ARM64v8"
|
|
|
|
COMMAND="$SETUP $LINUX_ARM64v8 $BUILD_COMPLETE"
|
|
|
|
elif [ "$BUILD" == "arm32v6" ]
|
|
|
|
then
|
|
|
|
echo "Building Linux ARM32v6"
|
|
|
|
COMMAND="$SETUP $LINUX_ARM32v6 $BUILD_COMPLETE"
|
|
|
|
elif [ "$BUILD" == "arm32v7" ]
|
|
|
|
then
|
|
|
|
echo "Building Linux ARM32v7"
|
|
|
|
COMMAND="$SETUP $LINUX_ARM32v7 $BUILD_COMPLETE"
|
|
|
|
else
|
|
|
|
echo "Building All"
|
2021-09-22 03:08:34 +00:00
|
|
|
COMMAND="$SETUP $WINDOWS $DARWIN $DARWIN_ARM64 $LINUX_AMD64 $LINUX_ARM64v8 $LINUX_ARM32v7 $LINUX_ARM32v6 $BUILD_COMPLETE"
|
2021-02-03 22:41:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Pull Latest Image
|
|
|
|
docker pull $COMPILER_CONTAINER
|
2019-02-10 12:16:29 +00:00
|
|
|
|
2021-02-03 22:41:43 +00:00
|
|
|
# Changed consistency to delegated since this is being used as a build tool. The binded volume shouldn't be changing during its run.
|
|
|
|
docker run --rm --mount type=bind,source="$(pwd)",target=/stash,consistency=delegated -w /stash $COMPILER_CONTAINER /bin/bash -c "$COMMAND"
|
2019-02-10 12:16:29 +00:00
|
|
|
|