#!/usr/bin/env bash set -eof pipefail GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) 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" exit 1 fi STATUS_GO_REPO="${STATUS_GO_REPO:=status-go}" STATUS_GO_OWNER="${STATUS_GO_OWNER:=status-im}" STATUS_GO_VERSION=$1 repoUrl="https://github.com/${STATUS_GO_OWNER}/${STATUS_GO_REPO}" STATUS_GO_COMMIT_SHA1=$(git ls-remote ${repoUrl} U ${STATUS_GO_VERSION} | cut -f1) if [[ -z "${STATUS_GO_COMMIT_SHA1}" ]]; then echo "Could not find SHA1 for rev ${STATUS_GO_VERSION}, assuming it's a commit." STATUS_GO_COMMIT_SHA1="${STATUS_GO_VERSION}" fi STATUS_GO_SHA256=$(nix-prefetch-url --unpack ${repoUrl}/archive/${STATUS_GO_VERSION}.zip) cat << EOF > ${GIT_ROOT}/status-go-version.json { "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "${STATUS_GO_OWNER}", "repo": "${STATUS_GO_REPO}", "version": "${STATUS_GO_VERSION}", "commit-sha1": "${STATUS_GO_COMMIT_SHA1}", "src-sha256": "${STATUS_GO_SHA256}" } EOF 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}"