-
Notifications
You must be signed in to change notification settings - Fork 0
/
version
executable file
·62 lines (52 loc) · 1.4 KB
/
version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
# Updates the repo to the a tagged/released version
# from the authoritative upstream repo
# OR to the latest stable release if no version specified
UPSTREAM=https://github.com/mentorpal/aws-beanstalk-app
LATEST_RELEASE_URL="${UPSTREAM}/releases/latest"
function get_latest_stable_release() {
URL=$(curl -Ls -o /dev/null -w %{url_effective} $1)
VERSION=$(basename ${URL})
if [[ -z $VERSION ]]; then
exit 1;
fi
echo $VERSION
exit 0;
}
function usage() {
echo "usage: version publish|switch [<tag>|--latest]"
}
cmd=$1
case $cmd in
publish|switch) ;;
*)
echo "unknown command '$cmd'"
usage
exit 1
;;
esac
tag=$2
if [[ -z "$tag" ]]; then
echo "you must pass a valid tag or '--latest'"
usage
exit 1
fi
if [[ "$tag" == "--latest" ]]; then
tag="$(get_latest_stable_release ${LATEST_RELEASE_URL})"
echo "using latest stable release version (${tag})"
fi
git remote show upstream > /dev/null 2>&1 && echo "" || git remote add upstream "${UPSTREAM}.git"
git lfs install
git fetch upstream --tags --force
git lfs fetch upstream
if [[ "$(git tag -l "$tag")" == "" ]]; then
echo "tag ${tag} not found. use 'git tag' to check available tags"
echo ""
usage
exit -1
fi
if [[ "$cmd" == "publish" ]]; then
git push origin refs/tags/${tag}
elif [[ "$cmd" == "switch" ]]; then
git reset --hard ${tag}
fi