2019-04-03 20:13:39 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-04-10 06:01:10 +01:00
|
|
|
set -eu
|
2019-04-03 20:13:39 +01:00
|
|
|
set -o pipefail
|
|
|
|
|
2019-04-10 06:01:10 +01:00
|
|
|
echo -n "Build timestamp: "
|
2019-04-03 20:13:39 +01:00
|
|
|
TIMESTAMP=$(date +%s)
|
|
|
|
echo $TIMESTAMP
|
|
|
|
|
2019-04-10 06:01:10 +01:00
|
|
|
echo -n "Git commit: "
|
2019-04-03 20:13:39 +01:00
|
|
|
if [[ "$(git diff --stat)" != '' ]] || [[ -n "$(git status -s)" ]]; then
|
2021-12-09 11:38:23 +00:00
|
|
|
echo "Changes detected, building a development version"
|
2019-04-03 20:13:39 +01:00
|
|
|
COMMIT=$(git rev-parse HEAD)-dirty
|
|
|
|
RELEASE=false
|
|
|
|
else
|
2021-12-09 11:38:23 +00:00
|
|
|
echo "Building a release version"
|
2019-04-03 20:13:39 +01:00
|
|
|
COMMIT=$(git rev-parse HEAD)
|
|
|
|
RELEASE=true
|
|
|
|
fi
|
|
|
|
echo $COMMIT
|
|
|
|
|
2019-04-10 06:01:10 +01:00
|
|
|
echo -n "Tagged version: "
|
2019-04-10 07:38:26 +01:00
|
|
|
if git describe --tags --exact-match --match "v[0-9]*.[0-9]*.[0-9]*"; then
|
|
|
|
VERSION=$(git describe --tags --exact-match --match "v[0-9]*.[0-9]*.[0-9]*")
|
|
|
|
echo $VERSION
|
|
|
|
else
|
|
|
|
VERSION=v0.0.0
|
|
|
|
RELEASE=false
|
|
|
|
fi
|
2019-04-03 20:13:39 +01:00
|
|
|
|
2019-04-10 06:01:10 +01:00
|
|
|
echo Running "go $@"
|
2019-04-03 20:13:39 +01:00
|
|
|
exec go "$1" -ldflags \
|
2020-10-14 08:00:28 +01:00
|
|
|
"-X storj.io/private/version.buildTimestamp=$TIMESTAMP
|
|
|
|
-X storj.io/private/version.buildCommitHash=$COMMIT
|
|
|
|
-X storj.io/private/version.buildVersion=$VERSION
|
|
|
|
-X storj.io/private/version.buildRelease=$RELEASE" "${@:2}"
|