1
1
#! /bin/bash
2
2
set -e
3
+ set -x
3
4
4
5
if [[ $# != 1 ]]; then
5
- echo " Missing parameter for version number "
6
+ echo " Missing parameter for version tag (vM.m.p) "
6
7
exit 1
7
8
fi
8
9
VERSION=" $1 "
9
10
11
+ case " $VERSION " in
12
+ v* .* .* ) ;;
13
+ * ) echo " Version parameter \" $VERSION \" is not in the expected format vM.m.p"
14
+ exit 1 ;;
15
+ esac
16
+
10
17
if [[ -z $CIRCLE_CI_TOKEN ]]; then
11
18
echo " Please provide a CircleCI API token in \$ CIRCLE_CI_TOKEN"
12
19
exit 1
@@ -17,17 +24,23 @@ if [[ -z $GITHUB_TOKEN ]]; then
17
24
exit 1
18
25
fi
19
26
20
- if [[ -z $GOPATH ]]; then
21
- echo " Please install Golang"
22
- exit 1
23
- fi
27
+ for tool in git curl jq gzip gpg; do
28
+ if ! command -v " $tool " > /dev/null; then
29
+ echo " Please install the required tool '$tool '"
30
+ exit 1
31
+ fi
32
+ done
24
33
25
- if ! [[ -f " $GOPATH /bin/ hub" ]] ; then
34
+ if ! command -v hub > /dev/null ; then
26
35
echo " Installing required tool Github 'hub'"
27
- go get github.com/github/hub
36
+ if ! command -v go > /dev/null; then
37
+ echo " Please install the Go language toolchain 'go' (needed to build 'hub')"
38
+ exit 1
39
+ fi
40
+ go install github.com/github/hub@latest
28
41
fi
29
42
30
- echo " Note: Make sure that you can sign commits on this machine with your GPG key: "
43
+ echo " Note: Make sure that you can sign git commits on this machine with your GPG key: "
31
44
echo " https://help.github.com/articles/signing-commits/"
32
45
echo " "
33
46
@@ -86,7 +99,7 @@ ARTIFACT_URLS=$(curl -s "https://circleci.com/api/v1.1/project/github/DataDog/dd
86
99
rm -rf .bin
87
100
mkdir .bin
88
101
cd .bin
89
- while read ARTIFACT_URL; do
102
+ while read -r ARTIFACT_URL; do
90
103
echo " Downloading artifact: ${ARTIFACT_URL} "
91
104
curl -s -L -O " ${ARTIFACT_URL} "
92
105
done <<< " $ARTIFACT_URLS"
@@ -105,7 +118,7 @@ for f in ./*; do
105
118
done
106
119
107
120
# Create a github release
108
- " $GOPATH /bin/ hub" release create --draft \
121
+ hub release create --draft \
109
122
" ${assets[@]} " \
110
123
-m " Release $VERSION " " $VERSION "
111
124
cd ..
0 commit comments