2018-05-07 09:22:14 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-10-22 11:56:13 +00:00
|
|
|
if [[ -z "${IN_NIX_SHELL}" ]]; then
|
|
|
|
echo "Remember to call 'make shell'!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-05-07 09:22:14 +00:00
|
|
|
set -eof pipefail
|
|
|
|
|
2019-06-04 17:00:19 +00:00
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
2019-03-25 16:35:01 +00:00
|
|
|
|
2018-05-08 07:58:04 +00:00
|
|
|
usage() {
|
|
|
|
printf "%s is a tool for upgrading status-go to a given version.\n" "$(basename "$0")"
|
|
|
|
printf "Usage:\n\n"
|
|
|
|
printf " %s version\n\n" "$(basename "$0")"
|
|
|
|
printf "Example:\n\n"
|
|
|
|
printf " %s develop-g12345678\n" "$(basename "$0")"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo "Need to provide a status-go version"
|
2018-05-07 09:22:14 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-07-22 03:31:47 +00:00
|
|
|
STATUS_GO_REPO="${STATUS_GO_REPO:=status-go}"
|
|
|
|
STATUS_GO_OWNER="${STATUS_GO_OWNER:=status-im}"
|
2019-05-02 11:29:10 +00:00
|
|
|
STATUS_GO_VERSION=$1
|
2019-07-22 03:31:47 +00:00
|
|
|
|
|
|
|
repoUrl="https://github.com/${STATUS_GO_OWNER}/${STATUS_GO_REPO}"
|
|
|
|
|
2019-07-19 18:42:16 +00:00
|
|
|
STATUS_GO_COMMIT_SHA1=$(git ls-remote ${repoUrl} U ${STATUS_GO_VERSION} | cut -f1)
|
|
|
|
|
2019-07-22 03:31:47 +00:00
|
|
|
if [[ -z "${STATUS_GO_COMMIT_SHA1}" ]]; then
|
|
|
|
echo "Could not find SHA1 for rev ${STATUS_GO_VERSION}, assuming it's a commit."
|
2019-11-05 08:21:02 +00:00
|
|
|
echo "WARNING: Setting 'version' value to 'develop'"
|
2019-07-22 03:31:47 +00:00
|
|
|
STATUS_GO_COMMIT_SHA1="${STATUS_GO_VERSION}"
|
2019-11-05 08:21:02 +00:00
|
|
|
STATUS_GO_VERSION="develop" # to reduce metrics cardinality in Prometheus
|
2019-07-22 03:31:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
STATUS_GO_SHA256=$(nix-prefetch-url --unpack ${repoUrl}/archive/${STATUS_GO_VERSION}.zip)
|
|
|
|
|
2019-07-19 18:42:16 +00:00
|
|
|
cat << EOF > ${GIT_ROOT}/status-go-version.json
|
|
|
|
{
|
|
|
|
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
|
|
|
|
"owner": "${STATUS_GO_OWNER}",
|
2019-07-22 03:31:47 +00:00
|
|
|
"repo": "${STATUS_GO_REPO}",
|
2019-07-19 18:42:16 +00:00
|
|
|
"version": "${STATUS_GO_VERSION}",
|
|
|
|
"commit-sha1": "${STATUS_GO_COMMIT_SHA1}",
|
|
|
|
"src-sha256": "${STATUS_GO_SHA256}"
|
|
|
|
}
|
2019-05-02 11:29:10 +00:00
|
|
|
EOF
|
|
|
|
|
2019-07-19 18:42:16 +00:00
|
|
|
echo "SHA-1 for ${STATUS_GO_VERSION} is ${STATUS_GO_COMMIT_SHA1}.
|
|
|
|
SHA-256 for source archive is ${STATUS_GO_SHA256}
|
|
|
|
Owner is ${STATUS_GO_OWNER}"
|