Skip to content
Snippets Groups Projects
Commit 10ee44d4 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] validating TX has not uid and avatar - Fix #729

[enh] release.sh use github token
parent 25dbb1dc
No related branches found
No related tags found
No related merge requests found
...@@ -13,58 +13,74 @@ fi ...@@ -13,58 +13,74 @@ fi
current=`grep -P "version\": \"\d+.\d+.\d+(\w*)" package.json | grep -oP "\d+.\d+.\d+(\w*)"` current=`grep -P "version\": \"\d+.\d+.\d+(\w*)" package.json | grep -oP "\d+.\d+.\d+(\w*)"`
echo "Current version: $current" 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 case "$1" in
del) del)
if [[ $2 =~ ^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$ ]]; then result=`curl -i "$REPO_URL/releases/tags/v$current"`
result=`curl -i 'https://api.github.com/repos/duniter/cesium/releases/tags/v'"$current"''` release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "$REPO_URL/releases/\d+"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://api.github.com/repos/duniter/cesium/releases/\d+"` if [[ $release_url != "" ]]; then
if [[ $release_url != "" ]]; then
echo "Deleting existing release..." echo "Deleting existing release..."
curl -XDELETE $release_url -u $2 curl -H 'Authorization: token $GITHUB_TOKEN' -XDELETE $release_url
fi
else
echo "Wrong argument"
echo "Usage:"
echo " > ./github.sh del user:password"
exit
fi fi
;; ;;
pre|rel) pre|rel)
if [[ $2 =~ ^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$ && $3 != "" ]]; then if [[ $2 != "" ]]; then
if [[ $1 = "pre" ]]; then if [[ $1 = "pre" ]]; then
prerelease="true" prerelease="true"
else else
prerelease="false" prerelease="false"
fi fi
description=`echo $2`
result=`curl -i 'https://api.github.com/repos/duniter/cesium/releases/tags/v'"$current"''` result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_URL/releases/tags/v$current"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://api.github.com/repos/duniter/cesium/releases/\d+"` release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+/releases/\d+"`
if [[ $release_url != "" ]]; then if [[ $release_url != "" ]]; then
echo "Deleting existing release..." 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 fi
echo "Creating new release..." 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"'}'` echo " - tag: v$current"
upload_url=`echo "$result" | grep -P "\"upload_url\": \"[^\"]+" | grep -oP "https://[a-z0-9/.]+"` 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 ### Sending files
echo "Uploading files to GitHub..." echo "Uploading files to GitHub..."
dirname=`pwd` 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 -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 -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 -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
# 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
echo "Successfully uploading files" echo "Successfully uploading files"
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://api.github.com/repos/[a-z0-9/.]+"` echo " -> Release url: https://github.com/$REPO/releases/tag/v$current"
echo " -> Release url: $release_url"
else else
echo "Wrong arguments" echo "Wrong arguments"
echo "Usage:" echo "Usage:"
echo " > ./github.sh pre|rel user:password <release_description>" echo " > ./github.sh pre|rel <release_description>"
echo "With:" echo "With:"
echo " - pre: use for pre-release" echo " - pre: use for pre-release"
echo " - rel: for full release" echo " - rel: for full release"
......
...@@ -40,6 +40,11 @@ if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then ...@@ -40,6 +40,11 @@ if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then
;; ;;
esac esac
# Load env.sh if exists
if [ -f "${DIRNAME}/env.sh" ]; then
source ${DIRNAME}/env.sh
fi
# force nodejs version to 5 # force nodejs version to 5
if [ -d "$NVM_DIR" ]; then if [ -d "$NVM_DIR" ]; then
. $NVM_DIR/nvm.sh . $NVM_DIR/nvm.sh
...@@ -60,7 +65,6 @@ if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then ...@@ -60,7 +65,6 @@ if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then
echo "----------------------------------" echo "----------------------------------"
echo "- Building Android artifact..." echo "- Building Android artifact..."
echo "----------------------------------" echo "----------------------------------"
source ./env.sh
ionic build android --release ionic build android --release
#ionic build firefoxos --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 ...@@ -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..." echo " Waiting 30s, for propagation to github..."
sleep 30s sleep 30s
if [[ $4 =~ ^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$ && "_$5" != "_" ]]; then if [[ "_$4" != "_" ]]; then
echo "**********************************" echo "**********************************"
echo "* Uploading artifacts to Github..." echo "* Uploading artifacts to Github..."
echo "**********************************" echo "**********************************"
./github.sh $1 $4 "'"$5"'" ./github.sh $1 $4
echo "----------------------------------" echo "----------------------------------"
echo "- Building desktop versions..." echo "- Building desktop versions..."
...@@ -129,12 +133,11 @@ cesium-desktop-v$2-linux-x64.tar.gz" ...@@ -129,12 +133,11 @@ cesium-desktop-v$2-linux-x64.tar.gz"
echo "* Build release succeed !" echo "* Build release succeed !"
echo "**********************************" echo "**********************************"
echo " WARN - missing arguments: " echo " WARN - missing arguments 'release_description'"
echo " user:password 'release_description'"
echo echo
echo " Binaries files NOT sending to github repository" echo " Binaries files NOT sending to github repository"
echo " Please run:" echo " Please run:"
echo " > ./github.sh pre|rel user:password 'release_description'" echo " > ./github.sh pre|rel 'release_description'"
echo echo
echo " Desktop artifact are NOT build" echo " Desktop artifact are NOT build"
echo " Please run:" echo " Please run:"
...@@ -145,10 +148,10 @@ cesium-desktop-v$2-linux-x64.tar.gz" ...@@ -145,10 +148,10 @@ cesium-desktop-v$2-linux-x64.tar.gz"
else else
echo "Wrong version format" echo "Wrong version format"
echo "Usage:" 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 "with:"
echo " version: x.y.z" echo " version: x.y.z"
echo " android-version: nnn" echo " android-version: nnn"
echo " github_credentials: user:password (a valid GitHub user account)" echo " release_description: a short description of the release"
fi fi
...@@ -5,7 +5,8 @@ angular.module('cesium.cache.services', ['angular-cache']) ...@@ -5,7 +5,8 @@ angular.module('cesium.cache.services', ['angular-cache'])
var var
constants = { 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 SHORT: csSettings.defaultSettings.cacheTimeMs
}, },
cacheNames = [] cacheNames = []
......
...@@ -159,7 +159,6 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -159,7 +159,6 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
var sliceTime = csSettings.data.walletHistorySliceSecond; var sliceTime = csSettings.data.walletHistorySliceSecond;
fromTime = fromTime - (fromTime % sliceTime); fromTime = fromTime - (fromTime % sliceTime);
for(var i = fromTime; i - sliceTime < nowInSec; i += 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}) jobs.push(BMA.tx.history.times({pubkey: pubkey, from: i, to: i+sliceTime-1})
.then(_reduceTx) .then(_reduceTx)
); );
...@@ -361,7 +360,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -361,7 +360,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
data.balance = balance; data.balance = balance;
// Will add uid (+ plugin will add name, avatar, etc. if enable) // 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() { .then(function() {
console.debug('[tx] TX and sources loaded in '+ (new Date().getTime()-now) +'ms'); console.debug('[tx] TX and sources loaded in '+ (new Date().getTime()-now) +'ms');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment