-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgithub-promote-release.sh
executable file
·97 lines (80 loc) · 2.63 KB
/
github-promote-release.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
shopt -s extglob
#set -x
USERNAME=reflectoring
REPOSITORY=infiniboard
GITHUB_PUSH_USER=matthiasbalke
if [ $# -ne 1 ];
then
echo "usage: github-promote-release.sh <RELEASE_VERSION>"
exit 1;
fi
if [ -z "$GITHUB_TOKEN" ]; then
echo "Environment variable GITHUB_TOKEN must be set. Aborting!"
exit 2;
fi
TAG_VERSION=$1
command -v jq >/dev/null 2>&1 || { echo >&2 "\"jq\" is required but it's not installed. Aborting."; exit 1; }
command -v github-release >/dev/null 2>&1 || {
case "$OSTYPE" in
darwin*) OS_TYPE=darwin ;;
bsd*) OS_TYPE=freebsd ;;
linux*) OS_TYPE=linux ;;
msys*) OS_TYPE=windows ;;
*) echo "\"github-release\" is not supported by your os type: $OSTYPE. Aborting."; exit 3 ;;
esac
echo >&2 "\"github-release\" is required but it's not installed. Installing $OS_TYPE version ...";
if [ ! -f ~/github-release.tar.bz2 ];
then
echo "downloading release: ~/github-release.tar.bz2 ..."
curl -L -o ~/github-release.tar.bz2 https://github.com/aktau/github-release/releases/download/v0.7.2/$OS_TYPE-amd64-github-release.tar.bz2
else
echo "using preloaded release: ~/github-release.tar.bz2 ..."
fi
mkdir -p ~/bin
tar --strip-components=3 -C ~/bin -jxf ~/github-release.tar.bz2
echo ""
command -v ~/bin/github-release >/dev/null 2>&1 || {
echo "installation of github-release failed. Aborting!"
exit 4;
}
}
echo "adding github remote ..."
git remote add github https://$GITHUB_PUSH_USER:[email protected]/$USERNAME/$REPOSITORY.git
echo "creating git tag '$TAG_VERSION' ..."
# create git tag
git tag -a $TAG_VERSION $CI_COMMIT_SHA -m "released version $TAG_VERSION"
echo ""
echo "pushing git tag $TAG_VERSION ..."
git push github $TAG_VERSION
echo ""
echo "creating github release draft $TAG_VERSION ..."
# create github release
~/bin/github-release release \
--user $USERNAME \
--repo $REPOSITORY \
--tag "$TAG_VERSION" \
--name "$TAG_VERSION" \
--description "Released on $(date +%Y-%m-%d)" \
--draft
echo ""
echo "uploading github release artifacts ..."
for artifact in {quartermaster/build/libs/quartermaster*.war,harvester/build/libs/harvester*.war}; do
echo "> $(basename $artifact)"
# upload artifacts
~/bin/github-release upload \
--user $USERNAME \
--repo $REPOSITORY \
--tag "$TAG_VERSION" \
--name "$(basename "$artifact")" \
--file "$artifact"
done
echo ""
echo "publishing github release ..."
~/bin/github-release edit \
--user $USERNAME \
--repo $REPOSITORY \
--tag "$TAG_VERSION" \
--name "$TAG_VERSION"
echo ""
echo "successfully created $USERNAME/$REPOSITORY release $TAG_VERSION !"