forked from prfalken/dellhw_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·66 lines (50 loc) · 1.7 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
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
#!/bin/bash
set -x
set -e
dir=$( dirname $0 )
if [ $# != 2 ]; then
echo "Usage: release.sh VERSION GITHUB_KEY"
exit 1
fi
version=$1
access_token=$2
require_clean_work_tree () {
# Update the index
git update-index -q --ignore-submodules --refresh
err=0
# Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules --
then
echo >&2 "cannot $1: you have unstaged changes."
git diff-files --name-status -r --ignore-submodules -- >&2
err=1
fi
# Disallow uncommitted changes in the index
if ! git diff-index --cached --quiet HEAD --ignore-submodules --
then
echo >&2 "cannot $1: your index contains uncommitted changes."
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
err=1
fi
if [ $err = 1 ]
then
echo >&2 "Please commit or stash them."
exit 1
fi
}
export VERSION=$version
${dir}/clean.sh
${dir}/build.sh
require_clean_work_tree
cd ${dir}/dist
tar cvzf dellhw_exporter-$version.linux-amd64.tar.gz *
cd -
git tag $version -a -m "Version $version"
git push --tags
sleep 5
posturl=$(curl --data "{\"tag_name\": \"$1\",\"target_commitish\": \"master\",\"name\": \"$1\",\"body\": \"Release of version $1\",\"draft\": false,\"prerelease\": false}" https://api.github.com/repos/PrFalken/dellhw_exporter/releases?access_token=${access_token} | grep "\"upload_url\"" | sed -ne 's/.*\(http[^"]*\).*/\1/p')
cd ${dir}/dist/
for filename in *.tar.gz ; do
curl -i -X POST -H "Content-Type: application/x-gzip" --data-binary "@${filename}" "${posturl%\{?name,label\}}?name=${filename}&label=${filename}&access_token=${access_token}"
done
cd -