From d44b830e0b283bccfa6615d8eba3f11df8479ec3 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Thu, 14 Sep 2017 07:31:27 +0200 Subject: [PATCH] releasing: Bump version also change dist/ --- dist/plugin.json | 2 +- release.sh | 43 ++++++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/dist/plugin.json b/dist/plugin.json index 1e7482a..8ab57b4 100644 --- a/dist/plugin.json +++ b/dist/plugin.json @@ -27,7 +27,7 @@ ], "screenshots": [ ], - "version": "1.5.4", + "version": "1.5.5", "updated": "2016-07-04" }, diff --git a/release.sh b/release.sh index e45fa1d..e4d3f61 100755 --- a/release.sh +++ b/release.sh @@ -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 @@ -7,14 +13,30 @@ 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) @@ -22,16 +44,17 @@ else 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} ? " @@ -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*