diff --git a/github.sh b/github.sh index 2f40d8a452ed91f4ab6efbff32dfcede79e49dc5..1d83811b5ac2adcb66a881455c219caf606cc57b 100755 --- a/github.sh +++ b/github.sh @@ -76,7 +76,7 @@ case "$1" in echo " - tag: v$current" echo " - description: $description" result=`curl -H ''"$GITHUT_AUTH"'' -s $REPO_API_URL/releases -d '{"tag_name": "v'"$current"'","target_commitish": "master","name": "'"$current"'","body": "'"$description"'","draft": false,"prerelease": '"$prerelease"'}'` - #echo "DEBUG - $result" + echo "DEBUG - $result" upload_url=`echo "$result" | grep -P "\"upload_url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"` if [[ "_$upload_url" = "_" ]]; then @@ -87,7 +87,7 @@ case "$1" in fi ### Sending files - echo "Uploading files to ${upload_url}" + echo "Uploading files to ${upload_url} ..." dirname=$(pwd) ZIP_FILE="$dirname/platforms/web/build/${PROJECT_NAME}-v$current-web.zip" diff --git a/release.sh b/release.sh index 5735b2676eaeef47acf24f1508236927e6aa5e1c..a9e591b6751af1f0ff35a9f437e9981d88a2f877 100755 --- a/release.sh +++ b/release.sh @@ -26,162 +26,162 @@ if [[ "_$currentAndroid" == "_" ]]; then fi echo "Current Android version: $currentAndroid" +# Check version format +if [[ ! $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ || ! $3 =~ ^[0-9]+$ ]]; then + echo "Wrong version format" + echo "Usage:" + echo " > ./release.sh [pre|rel] <version> <android-version> <release_description>" + echo "with:" + echo " - pre: use for pre-release" + echo " - rel: for full release" + echo " - version: x.y.z" + echo " - android-version: nnn" + echo " - release_description: a comment on release" + exit 1 +fi -### Releasing -if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then - - echo "new build version: $2" - echo "new build android version: $3" - case "$1" in - rel|pre) - # Change the version in files: 'package.json' and 'config.xml' - sed -i "s/version\": \"$current\"/version\": \"$2\"/g" package.json - currentConfigXmlVersion=`grep -oP "version=\"\d+.\d+.\d+((a|b)[0-9]+)?\"" config.xml | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?"` - sed -i "s/ version=\"$currentConfigXmlVersion\"/ version=\"$2\"/g" config.xml - sed -i "s/ android-versionCode=\"$currentAndroid\"/ android-versionCode=\"$3\"/g" config.xml - - # Change version in file: 'www/manifest.json' - currentManifestJsonVersion=`grep -oP "version\": \"\d+.\d+.\d+((a|b)[0-9]+)?\"" www/manifest.json | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?"` - sed -i "s/version\": \"$currentManifestJsonVersion\"/version\": \"$2\"/g" www/manifest.json - - # Bump the install.sh - sed -i "s/echo \"v.*\" #lastest/echo \"v$2\" #lastest/g" install.sh - ;; - *) - echo "No task given" - exit 1 - ;; - esac - - # Load env.sh if exists - if [[ -f "${DIRNAME}/.local/env.sh" ]]; then - echo "Loading .local/env.sh ..." - source "${DIRNAME}/.local/env.sh" $* - fi - - # Check the Java version - JAVA_VERSION=`java -version 2>&1 | egrep "(java|openjdk) version" | awk '{print $3}' | tr -d \"` - if [[ $? -ne 0 ]]; then - echo "No Java JRE 1.8 found in machine. This is required for Android artifacts." +echo "new build version: $2" +echo "new build android version: $3" +case "$1" in + rel|pre) + # Change the version in files: 'package.json' and 'config.xml' + sed -i "s/version\": \"$current\"/version\": \"$2\"/g" package.json + currentConfigXmlVersion=`grep -oP "version=\"\d+.\d+.\d+((a|b)[0-9]+)?\"" config.xml | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?"` + sed -i "s/ version=\"$currentConfigXmlVersion\"/ version=\"$2\"/g" config.xml + sed -i "s/ android-versionCode=\"$currentAndroid\"/ android-versionCode=\"$3\"/g" config.xml + + # Change version in file: 'www/manifest.json' + currentManifestJsonVersion=`grep -oP "version\": \"\d+.\d+.\d+((a|b)[0-9]+)?\"" www/manifest.json | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?"` + sed -i "s/version\": \"$currentManifestJsonVersion\"/version\": \"$2\"/g" www/manifest.json + + # Bump the install.sh + sed -i "s/echo \"v.*\" #lastest/echo \"v$2\" #lastest/g" install.sh + ;; + *) + echo "No task given" exit 1 - fi - JAVA_MAJOR_VERSION=`echo ${JAVA_VERSION} | awk '{split($0, array, ".")} END{print array[1]}'` - JAVA_MINOR_VERSION=`echo ${JAVA_VERSION} | awk '{split($0, array, ".")} END{print array[2]}'` - if [[ ${JAVA_MAJOR_VERSION} -ne 1 ]] || [[ ${JAVA_MINOR_VERSION} -ne 8 ]]; then - echo "Require a Java JRE in version 1.8, but found ${JAVA_VERSION}. You can override your default JAVA_HOME in '.local/env.sh'." - exit 1 - fi - echo "Java: $JAVA_VERSION" - + ;; +esac - # force nodejs version to 6 - if [[ -d "$NVM_DIR" ]]; then - . $NVM_DIR/nvm.sh - nvm use 6 - if [[ $? -ne 0 ]]; then - exit 1 - fi - else - echo "nvm (Node version manager) not found (directory $NVM_DIR not found). Please install, and retry" - exit 1 - fi +# Load env.sh if exists +if [[ -f "${DIRNAME}/.local/env.sh" ]]; then + echo "Loading .local/env.sh ..." + source "${DIRNAME}/.local/env.sh" $* +fi - # Update config file - gulp config --env default_fr +# Check the Java version +JAVA_VERSION=`java -version 2>&1 | egrep "(java|openjdk) version" | awk '{print $3}' | tr -d \"` +if [[ $? -ne 0 ]]; then + echo "No Java JRE 1.8 found in machine. This is required for Android artifacts." + exit 1 +fi +JAVA_MAJOR_VERSION=`echo ${JAVA_VERSION} | awk '{split($0, array, ".")} END{print array[1]}'` +JAVA_MINOR_VERSION=`echo ${JAVA_VERSION} | awk '{split($0, array, ".")} END{print array[2]}'` +if [[ ${JAVA_MAJOR_VERSION} -ne 1 ]] || [[ ${JAVA_MINOR_VERSION} -ne 8 ]]; then + echo "Require a Java JRE in version 1.8, but found ${JAVA_VERSION}. You can override your default JAVA_HOME in '.local/env.sh'." + exit 1 +fi +echo "Java: $JAVA_VERSION" - echo "----------------------------------" - echo "- Compiling sources..." - echo "----------------------------------" - gulp - echo "----------------------------------" - echo "- Building Android artifact..." - echo "----------------------------------" - rm -rf platforms/android/build/outputs/release/* - ionic build android --release +# force nodejs version to 6 +if [[ -d "$NVM_DIR" ]]; then + . $NVM_DIR/nvm.sh + nvm use 6 if [[ $? -ne 0 ]]; then exit 1 fi +else + echo "nvm (Node version manager) not found (directory $NVM_DIR not found). Please install, and retry" + exit 1 +fi - echo "----------------------------------" - echo "- Building web artifact..." - echo "----------------------------------" +# Update config file +gulp config --env default_fr - # Update config file - gulp config --env default - gulp build:web --release - if [[ $? -ne 0 ]]; then - exit 1 - fi +echo "----------------------------------" +echo "- Compiling sources..." +echo "----------------------------------" +gulp - echo "----------------------------------" - echo "- Executing git push, with tag: v$2" - echo "----------------------------------" - - # Commit - cd $DIRNAME - git reset HEAD - git add package.json config.xml install.sh www/js/config.js www/manifest.json - git commit -m "v$2" - git tag "v$2" - git push - if [[ $? -ne 0 ]]; then - exit 1 - fi +echo "----------------------------------" +echo "- Building Android artifact..." +echo "----------------------------------" +rm -rf platforms/android/build/outputs/release/* +ionic build android --release +if [[ $? -ne 0 ]]; then + exit 1 +fi - # Pause (wait propagation to from git.duniter.org to github) - echo " Waiting 30s, for propagation to github..." - sleep 30s +echo "----------------------------------" +echo "- Building web artifact..." +echo "----------------------------------" - description="$4" - if [[ "_$description" == "_" ]]; then - description="Release v$2" - fi +# Update config file +gulp config --env default +gulp build:web --release +if [[ $? -ne 0 ]]; then + exit 1 +fi - echo "**********************************" - echo "* Uploading artifacts to Github..." - echo "**********************************" +echo "----------------------------------" +echo "- Executing git push, with tag: v$2" +echo "----------------------------------" + +# Commit +cd $DIRNAME +git reset HEAD +git add package.json config.xml install.sh www/js/config.js www/manifest.json +git commit -m "v$2" +git tag "v$2" +git push +if [[ $? -ne 0 ]]; then + exit 1 +fi - ./github.sh $1 ''"$description"'' - if [[ $? -ne 0 ]]; then - exit 1 - fi +# Pause (wait propagation to from git.duniter.org to github) +echo " Waiting 30s, for propagation to github..." +sleep 40s - echo "----------------------------------" - echo "- Building desktop artifacts..." - echo "----------------------------------" +description="$4" +if [[ "_$description" == "_" ]]; then + description="Release v$2" +fi - git submodule init - git submodule sync - git submodule update --remote --merge +echo "**********************************" +echo "* Uploading artifacts to Github..." +echo "**********************************" - if [[ -d "$DIRNAME/platforms/desktop" ]]; then - cd platforms/desktop +./github.sh $1 ''"$description"'' +if [[ $? -ne 0 ]]; then + exit 1 +fi - # Build desktop assets - ./release.sh $2 - if [[ $? -ne 0 ]]; then - exit 1 - fi - else - echo "WARN: platform/desktop not found -> Skipping desktop build!" - fi; +echo "----------------------------------" +echo "- Building desktop artifacts..." +echo "----------------------------------" - # back to nodejs version 6 - cd $DIRNAME - nvm use 6 +git submodule init +git submodule sync +git submodule update --remote --merge - echo "**********************************" - echo "* Build release succeed !" - echo "**********************************" +if [[ -d "$DIRNAME/platforms/desktop" ]]; then + cd platforms/desktop + # Build desktop assets + ./release.sh $2 + if [[ $? -ne 0 ]]; then + exit 1 + fi else - echo "Wrong version format" - echo "Usage:" - echo " > ./release.sh [pre|rel] <version> <android-version> <release_description>" - echo "with:" - echo " version: x.y.z" - echo " android-version: nnn" - echo " release_description: a short description of the release" -fi + echo "WARN: platform/desktop not found -> Skipping desktop build!" +fi; + +# back to nodejs version 6 +cd $DIRNAME +nvm use 6 + +echo "**********************************" +echo "* Build release succeed !" +echo "**********************************"