diff --git a/github.sh b/github.sh index e1a4c46fc28988036199e276ba946d67be4ee451..5289960c2c7645ccfcd1f074e50f9c9414643ebd 100755 --- a/github.sh +++ b/github.sh @@ -13,58 +13,74 @@ fi current=`grep -P "version\": \"\d+.\d+.\d+(\w*)" package.json | 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/[^/]+/[^/ ]+"` +REPO=`echo $REMOTE_URL | sed "s/https:\/\/github.com\///g"` +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 authentifcation 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 +fi + case "$1" in del) - if [[ $2 =~ ^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$ ]]; then - result=`curl -i 'https://api.github.com/repos/duniter/cesium/releases/tags/v'"$current"''` - release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://api.github.com/repos/duniter/cesium/releases/\d+"` - if [[ $release_url != "" ]]; then + 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 -XDELETE $release_url -u $2 - fi - else - echo "Wrong argument" - echo "Usage:" - echo " > ./github.sh del user:password" - exit + curl -H 'Authorization: token $GITHUB_TOKEN' -XDELETE $release_url fi ;; pre|rel) - if [[ $2 =~ ^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$ && $3 != "" ]]; then + if [[ $2 != "" ]]; then if [[ $1 = "pre" ]]; then prerelease="true" else prerelease="false" fi + description=`echo $2` - result=`curl -i 'https://api.github.com/repos/duniter/cesium/releases/tags/v'"$current"''` - release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://api.github.com/repos/duniter/cesium/releases/\d+"` + 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..." - curl -XDELETE $release_url -u $2 + result=`curl -H ''"$GITHUT_AUTH"'' -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 + fi + else + echo "Release not exists yet on github." fi echo "Creating new release..." - result=`curl -i https://api.github.com/repos/duniter/cesium/releases -u $2 -d '{"tag_name": "v'"$current"'","target_commitish": "master","name": "'"$current"'","body": "'"$3"'","draft": false,"prerelease": '"$prerelease"'}'` - upload_url=`echo "$result" | grep -P "\"upload_url\": \"[^\"]+" | grep -oP "https://[a-z0-9/.]+"` + echo " - tag: v$current" + echo " - description: $description" + result=`curl -H ''"$GITHUT_AUTH"'' -i $REPO_URL/releases -d '{"tag_name": "v'"$current"'","target_commitish": "master","name": "'"$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 GitHub..." dirname=`pwd` - curl -i -u $2 -H 'Content-Type: application/zip' -T $dirname/platforms/web/build/cesium-v$current-web.zip $upload_url?name=cesium-v$current-web.zip - curl -i -u $2 -H 'Content-Type: application/vnd.android.package-archive' -T $dirname/platforms/android/build/outputs/apk/release/android-release.apk $upload_url?name=cesium-v$current-android.apk - # curl -i -u $2 -H 'Content-Type: application/zip' -T $dirname/platforms/firefoxos/build/package.zip $upload_url?name=cesium-v$current-firefoxos.zip - # curl -i -u $2 -H 'Content-Type: application/x-debian-package' -T $dirname/platforms/ubuntu/native/cesium_${current}_amd64.deb $upload_url?name=cesium-v${current}-ubuntu-amd64.deb + curl -i -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T $dirname/platforms/web/build/cesium-v$current-web.zip $upload_url?name=cesium-v$current-web.zip + curl -i -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/vnd.android.package-archive' -T $dirname/platforms/android/build/outputs/apk/release/android-release.apk $upload_url?name=cesium-v$current-android.apk echo "Successfully uploading files" - release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://api.github.com/repos/[a-z0-9/.]+"` - echo " -> Release url: $release_url" + echo " -> Release url: https://github.com/$REPO/releases/tag/v$current" else echo "Wrong arguments" echo "Usage:" - echo " > ./github.sh pre|rel user:password <release_description>" + echo " > ./github.sh pre|rel <release_description>" echo "With:" echo " - pre: use for pre-release" echo " - rel: for full release" diff --git a/release.sh b/release.sh index 42ce22a122eaad518666bad91ae83b9b2de374ac..d63f3cb070e9fecbccb2740da827c6a52d1259e4 100755 --- a/release.sh +++ b/release.sh @@ -40,6 +40,11 @@ if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then ;; esac + # Load env.sh if exists + if [ -f "${DIRNAME}/env.sh" ]; then + source ${DIRNAME}/env.sh + fi + # force nodejs version to 5 if [ -d "$NVM_DIR" ]; then . $NVM_DIR/nvm.sh @@ -60,7 +65,6 @@ if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then echo "----------------------------------" echo "- Building Android artifact..." echo "----------------------------------" - source ./env.sh ionic build android --release #ionic build firefoxos --release @@ -91,12 +95,12 @@ if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then echo " Waiting 30s, for propagation to github..." sleep 30s - if [[ $4 =~ ^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$ && "_$5" != "_" ]]; then + if [[ "_$4" != "_" ]]; then echo "**********************************" echo "* Uploading artifacts to Github..." echo "**********************************" - ./github.sh $1 $4 "'"$5"'" + ./github.sh $1 $4 echo "----------------------------------" echo "- Building desktop versions..." @@ -129,12 +133,11 @@ cesium-desktop-v$2-linux-x64.tar.gz" echo "* Build release succeed !" echo "**********************************" - echo " WARN - missing arguments: " - echo " user:password 'release_description'" + echo " WARN - missing arguments 'release_description'" echo echo " Binaries files NOT sending to github repository" echo " Please run:" - echo " > ./github.sh pre|rel user:password 'release_description'" + echo " > ./github.sh pre|rel 'release_description'" echo echo " Desktop artifact are NOT build" echo " Please run:" @@ -145,10 +148,10 @@ cesium-desktop-v$2-linux-x64.tar.gz" else echo "Wrong version format" echo "Usage:" - echo " > ./release.sh [pre|rel] <version> <android-version> <github_credentials>" + echo " > ./release.sh [pre|rel] <version> <android-version> <release_description>" echo "with:" echo " version: x.y.z" echo " android-version: nnn" - echo " github_credentials: user:password (a valid GitHub user account)" + echo " release_description: a short description of the release" fi diff --git a/www/js/services/cache-services.js b/www/js/services/cache-services.js index 310d58a23a40de888a74e24719ace0e9be6e82bc..c84a8812e7d29d3db84edb9e309193f2a6e52956 100644 --- a/www/js/services/cache-services.js +++ b/www/js/services/cache-services.js @@ -5,7 +5,8 @@ angular.module('cesium.cache.services', ['angular-cache']) var constants = { - LONG: 1 * 60 * 60 * 1000 /*5 min*/, + LONG: 1 * 60 * 60 * 1000 /*1 hour*/, + MEDIUM: 5 * 60 * 1000 /*5 min*/, SHORT: csSettings.defaultSettings.cacheTimeMs }, cacheNames = [] diff --git a/www/js/services/tx-services.js b/www/js/services/tx-services.js index 32d949ba4c80439657f264e33f062226f361f3c1..b0a3df8b6c3ad7f99f1f867f9858ab64b7a28741 100644 --- a/www/js/services/tx-services.js +++ b/www/js/services/tx-services.js @@ -159,7 +159,6 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', var sliceTime = csSettings.data.walletHistorySliceSecond; fromTime = fromTime - (fromTime % sliceTime); for(var i = fromTime; i - sliceTime < nowInSec; i += sliceTime) { - var startTime = Math.max(i, fromTime); jobs.push(BMA.tx.history.times({pubkey: pubkey, from: i, to: i+sliceTime-1}) .then(_reduceTx) ); @@ -361,7 +360,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', data.balance = balance; // Will add uid (+ plugin will add name, avatar, etc. if enable) - return csWot.extendAll((data.tx.history || []).concat(data.tx.pendings||[]), 'pubkey'); + return csWot.extendAll((data.tx.history || []).concat(data.tx.validating||[]).concat(data.tx.pendings||[]), 'pubkey'); }) .then(function() { console.debug('[tx] TX and sources loaded in '+ (new Date().getTime()-now) +'ms');