-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-image.sh
executable file
·56 lines (47 loc) · 1.21 KB
/
release-image.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
#!/bin/bash
VERSION=$(cat VERSION)
DRY_RUN=false
GITHUB_USERNAME=${GITHUB_USERNAME:-}
GITHUB_TOKEN=${GITHUB_TOKEN:-}
info() {
echo -e "\033[0;32m$1\033[0m"
}
warn() {
echo -e "\033[0;93m$1\033[0m"
}
error() {
echo -e "\033[0;91m$1\033[0m" >&2
}
if ! command -v curl > /dev/null; then
error "[Fail] Not install curl"
exit 1
fi
if [ "${1:-}" == "--dry-run" ]; then
warn "[Dry run mode]"
DRY_RUN=true
fi
tag="$VERSION"
name="primehub-usage $VERSION"
info "[Release] Primehub-usage with version $VERSION"
echo " name: $name"
echo " tag: $tag"
if [ "$GITHUB_USERNAME" == "" ]; then
read -p "Please provide Github username: " GITHUB_USERNAME
fi
if [ "$GITHUB_TOKEN" == "" ]; then
read -s -p "Please provide Github token: " GITHUB_TOKEN
echo ""
fi
info "[Auth] Github"
echo "Username: $GITHUB_USERNAME"
echo "Token: $(echo "$GITHUB_TOKEN" | sed "s/\(.\{6\}\).*/\1********/g")"
if [ "$DRY_RUN" == false ]; then
info "[Create] release $name with tag $tag"
curl \
-i \
-u ${GITHUB_USERNAME}:${GITHUB_TOKEN} \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/infuseai/primehub-usage/releases \
-d "{\"tag_name\":\"$tag\", \"name\":\"$name\"}"
fi