Skip to content

Commit

Permalink
releasing: Bump version also change dist/
Browse files Browse the repository at this point in the history
  • Loading branch information
sileht committed Sep 14, 2017
1 parent e212d39 commit d44b830
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"screenshots": [
],
"version": "1.5.4",
"version": "1.5.5",
"updated": "2016-07-04"
},

Expand Down
43 changes: 32 additions & 11 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/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

Expand All @@ -7,31 +13,48 @@ 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
sed -i 's/"version": "[^"]*"/"version": "'$version'"/' plugin.json package.json
./run-tests.sh
git commit -m "Bump version $version" plugin.json package.json
git push
bump_version "$version" "$today"
fi
else
version=$(git tag | tail -1)
version=$(inc_version $version)
fi

# Sanity checks
[ ! "$GITHUB_TOKEN" ] && error "GITHUB_TOKEN is missing"
[ "$(get_version plugin.json)" != "$version" ] && error "plugin.json incorrect version"
[ "$(get_version package.json)" != "$version" ] && error "package.json incorrect version"
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"
[ -z "$status" ] || error "Repo is not clean after dist/ generation"

echo
echo "release: ${version} ? "
Expand All @@ -49,8 +72,6 @@ github-release release -u gnocchixyz -r grafana-gnocchi-datasource --tag $versio
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

nextversion=$(inc_version $version)
sed -i 's/"version": "'$version'"/"version": "'$nextversion'"/' plugin.json package.json
git commit -m "Bump version $nextversion" plugin.json package.json
git push
bump_version "$nextversion" "$today"

rm -rf gnocchixyz-gnocchi-datasource*

0 comments on commit d44b830

Please sign in to comment.