forked from marshell08/grafana-plugins
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrelease.sh
executable file
·79 lines (58 loc) · 2.47 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
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#
# Grafana plugin plublisher here: https://grafana.com/plugins/gnocchixyz-gnocchi-datasource
# are built from github, asking are done with PR here: https://github.com/grafana/grafana-plugin-repository
# they release tools clones our git at the asked tag and create a tarball of the dist/ directory.
# So on each release the dist/ up2date
set -e
cd $(readlink -f $(dirname $0))
inc_version() { echo $1 | gawk -F"." '{$NF+=1}{print $0RT}' OFS="." ORS="" ;}
get_version() { sed -n 's/.*"version": "\([^"]*\)".*/\1/gp' $1 ; }
error() { echo $1 ; exit 1 ; }
bump_version() {
nextversion=$1
today=$today
sed -i 's/"version": "[^"]*"/"version": "'$nextversion'"/' plugin.json package.json
sed -i 's/"updated": "[^"]*"/"updated": "'$today'"/' plugin.json
./run-tests.sh
status=$(git status -sz)
if [ -n "$status" ]; then
git commit -m "Bump version $nextversion" plugin.json package.json dist/
git push
fi
}
[ ! "$GITHUB_TOKEN" ] && error "GITHUB_TOKEN is missing"
today=$(date "+%Y-%m-%d")
git fetch origin --tags
if [ "$1" ] ; then
version="$1"
if [ "$(get_version plugin.json)" != "$version" ]; then
bump_version "$version" "$today"
fi
else
version=$(git tag | tail -1)
version=$(inc_version $version)
fi
# Sanity checks
plugin_version=$(get_version plugin.json)
package_version=$(get_version package.json)
[ "$plugin_version" != "$version" ] && error "plugin.json incorrect version ($plugin_version != $version)"
[ "$package_version" != "$version" ] && error "package.json incorrect version ($package_version != $version"
echo "Building version $version"
./run-tests.sh
status=$(git status -sz)
[ -z "$status" ] || error "Repo is not clean after dist/ generation"
echo
echo "release: ${version} ? "
echo
read
cp -a dist gnocchixyz-gnocchi-datasource
tar -czf gnocchixyz-gnocchi-datasource-${version}.tar.gz gnocchixyz-gnocchi-datasource
git tag $version -m "Release version $version"
git push --tags
github-release release -u gnocchixyz -r grafana-gnocchi-datasource --tag $version --description "Release $version for Grafana 3 and 4"
github-release upload -u gnocchixyz -r grafana-gnocchi-datasource --tag $version --name gnocchixyz-gnocchi-datasource-${version}.tar.gz --file gnocchixyz-gnocchi-datasource-${version}.tar.gz
github-release info -u gnocchixyz -r grafana-gnocchi-datasource --tag $version
rm -rf gnocchixyz-gnocchi-datasource*
nextversion=$(inc_version $version)
bump_version "$nextversion" "$today"