-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·38 lines (27 loc) · 1.37 KB
/
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
#!/bin/bash
GITHUB_REPO=HIP-infrastructure/hip
APP_NAME=hip
[ -z "$GITHUB_TOKEN" ] && echo GITHUB_TOKEN var is missing. Go to https://github.com/settings/tokens && exit 1
git diff --quiet --exit-code
[ $? != 0 ] && echo There is unstaged changes && exit 1
VERSION=v`grep '<version>' appinfo/info.xml | sed 's/[^0-9.]//g'`
PRE=false
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [[ "$BRANCH" != "master" ]]; then
PRE=true
VERSION="$VERSION-pre-release+$(git rev-parse --short HEAD)"
fi
echo "{\"tag_name\":\"$VERSION\", \"prerelease\":$PRE}"
UPLOAD_URL=`curl \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"tag_name\":\"$VERSION\", \"prerelease\":$PRE}" \
https://api.github.com/repos/$GITHUB_REPO/releases` # | grep '"upload_url"' | sed 's/.*"\(https:.*\){.*/\1/'`
[ -z "$UPLOAD_URL" ] && echo Can not get upload url && exit 1
echo $UPLOAD_URL
git tag $VERSION
curl -sH "Authorization: token $GITHUB_TOKEN" -H 'Content-Type: application/octet-stream' --data-binary '@release.tar.gz' ${UPLOAD_URL}?name=release.tar.gz > /dev/null
LATEST_RELEASE_URL=`curl -sH "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPO/releases/latest | grep '"browser_download_url"' | head -1 | egrep -o 'https.*.gz'`
[ -z "$LATEST_RELEASE_URL" ] && echo Can not get upload url && exit 1
echo Release published at:
echo $LATEST_RELEASE_URL