From 713ccea5f5f6c98a84fe87ee3dc3bc2a3a3cbfbd Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Mon, 31 Dec 2018 16:36:38 +0100 Subject: [PATCH] prepare next version --- cesium-plus-pod-assembly/pom.xml | 2 +- cesium-plus-pod-core/pom.xml | 2 +- cesium-plus-pod-subscription/pom.xml | 2 +- cesium-plus-pod-user/pom.xml | 2 +- github.sh | 96 ++++++++++++++++++++++++++++ release.sh | 37 +++++++++++ src/site/site.xml | 2 +- 7 files changed, 138 insertions(+), 5 deletions(-) create mode 100755 github.sh create mode 100755 release.sh diff --git a/cesium-plus-pod-assembly/pom.xml b/cesium-plus-pod-assembly/pom.xml index e5fb9f93..6a99850b 100644 --- a/cesium-plus-pod-assembly/pom.xml +++ b/cesium-plus-pod-assembly/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.1.3-SNAPSHOT</version> + <version>1.1.3</version> </parent> <artifactId>cesium-plus-pod-assembly</artifactId> diff --git a/cesium-plus-pod-core/pom.xml b/cesium-plus-pod-core/pom.xml index ea3378a6..19411a5b 100644 --- a/cesium-plus-pod-core/pom.xml +++ b/cesium-plus-pod-core/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.1.3-SNAPSHOT</version> + <version>1.1.3</version> </parent> <artifactId>cesium-plus-pod-core</artifactId> diff --git a/cesium-plus-pod-subscription/pom.xml b/cesium-plus-pod-subscription/pom.xml index 9d16ed30..be572ffc 100644 --- a/cesium-plus-pod-subscription/pom.xml +++ b/cesium-plus-pod-subscription/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.1.3-SNAPSHOT</version> + <version>1.1.3</version> </parent> <artifactId>cesium-plus-pod-subscription</artifactId> diff --git a/cesium-plus-pod-user/pom.xml b/cesium-plus-pod-user/pom.xml index db578c32..3c1c13ae 100644 --- a/cesium-plus-pod-user/pom.xml +++ b/cesium-plus-pod-user/pom.xml @@ -3,7 +3,7 @@ <parent> <artifactId>cesium-plus-pod</artifactId> <groupId>org.duniter.cesium</groupId> - <version>1.1.3-SNAPSHOT</version> + <version>1.1.3</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/github.sh b/github.sh new file mode 100755 index 00000000..f35ad22e --- /dev/null +++ b/github.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +### Control that the script is run on `dev` branch +branch=`git rev-parse --abbrev-ref HEAD` +if [[ "$branch" = "master" ]]; +then + echo ">> This script must be run under a branch (tag)" + exit 1 +fi + +### Get version to release +current=`grep -m1 -P "\<version>[0-9A−Z.]+(-\w*)?</version>" pom.xml | grep -oP "\d+.\d+.\d+(-\w*)?"` +echo "Current version: $current" + +### Get repo URL +REMOTE_URL=`git remote -v | grep -P "push" | grep -oP "(https:\/\/github.com\/|git@github.com:)[^ ]+"` +REPO=`echo $REMOTE_URL | sed "s/https:\/\/github.com\///g" | sed "s/git@github.com://g" | sed "s/.git$//"` +REPO_URL=https://api.github.com/repos/$REPO + +### get auth token +GITHUB_TOKEN=`cat ~/.config/duniter/.github` +if [[ "_$GITHUB_TOKEN" != "_" ]]; then + GITHUT_AUTH="Authorization: token $GITHUB_TOKEN" +else + echo "Unable to find github authentication token file: " + echo " - You can create such a token at https://github.com/settings/tokens > 'Generate a new token'." + echo " - Then copy the token and paste it in the file '~/.config/duniter/.github' using a valid token." + exit 1 +fi + +case "$1" in + del) + result=`curl -i "$REPO_URL/releases/tags/v$current"` + release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "$REPO_URL/releases/\d+"` + if [[ $release_url != "" ]]; then + echo "Deleting existing release..." + curl -H 'Authorization: token $GITHUB_TOKEN' -XDELETE $release_url + fi + ;; + + pre|rel) + + if [[ $1 = "pre" ]]; then + prerelease="true" + else + prerelease="false" + fi + + description=`echo $2` + if [[ "_$description" = "_" ]]; then + description="Release v$current" + fi + + result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_URL/releases/tags/v$current"` + release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+/releases/\d+"` + if [[ "_$release_url" != "_" ]]; then + echo "Deleting existing release... $release_url" + result=`curl -H ''"$GITHUT_AUTH"'' -s -XDELETE $release_url` + if [[ "_$result" != "_" ]]; then + error_message=`echo "$result" | grep -P "\"message\": \"[^\"]+" | grep -oP ": \"[^\"]+\""` + echo "Delete existing release failed with error$error_message" + exit 1 + fi + else + echo "Release not exists yet on github." + fi + + echo "Creating new release..." + echo " - tag: v$current" + echo " - description: $description" + result=`curl -H ''"$GITHUT_AUTH"'' -s $REPO_URL/releases -d '{"tag_name": "v'"$current"'","target_commitish": "master","name": "v'"$current"'","body": "'"$description"'","draft": false,"prerelease": '"$prerelease"'}'` + upload_url=`echo "$result" | grep -P "\"upload_url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"` + + ### Sending files + echo "Uploading files... to $upload_url" + dirname=`pwd` + + result=`curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "$dirname/cesium-plus-pod-assembly/target/cesium-plus-pod-$current-standalone.jar" "$upload_url?name=cesium-plus-pod-$current-standalone.jar"` + browser_download_url=`echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"` + echo " - $browser_download_url" + + echo "-----------------------------------------" + echo "Successfully uploading files to github !" + + ;; + *) + echo "Missing arguments" + echo "Usage:" + echo " > ./github.sh del|pre|rel <release_description>" + echo "With:" + echo " - del: delete existing release" + echo " - pre: use for pre-release" + echo " - rel: for full release" + exit 1 + ;; +esac diff --git a/release.sh b/release.sh new file mode 100755 index 00000000..c6b487e9 --- /dev/null +++ b/release.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +echo "**********************************" +echo "* Preparing release..." +echo "**********************************" +result=`mvn release:clean` +failure=`echo "$result" | grep -m1 -P "\[INFO\] BUILD FAILURE" | grep -oP "BUILD \w+"` +# prepare failed +if [[ ! "_$failure" = "_" ]]; then + echo "$result" | grep -P "\[ERROR\] " + exit 1 +fi + +mvn release:prepare --quiet +if [ $? -ne 0 ]; then + exit 1 +fi + +echo "**********************************" +echo "* Performing release..." +echo "**********************************" +mvn release:perform --quiet +if [ $? -ne 0 ]; then + exit 1 +fi + +echo "**********************************" +echo "* Uploading artifacts to Github..." +echo "**********************************" +cd $dirname/target/checkout +./github.sh pre +if [ $? -ne 0 ]; then + exit 1 +fi + +echo "RELEASE finished !" + diff --git a/src/site/site.xml b/src/site/site.xml index dd001169..8d2b10df 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -78,7 +78,7 @@ <menu name="${project.name}" inherit="top"> <item name="Home" href="./index.html"/> <item name="Downloads" - href="https://github.com/duniter/duniter4j/releases"/> + href="https://github.com/duniter/cesium-plus-pod/releases"/> </menu> <menu name="User manual" inherit="top"> -- GitLab