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

New script to upload assets to github

parent 10bc2f7c
No related branches found
No related tags found
No related merge requests found
#!/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 \`master\` branch"
exit
fi
### Releasing
current=`grep -P "version\": \"\d+.\d+.\d+(\w*)" package.json | grep -oP "\d+.\d+.\d+(\w*)"`
echo "Current version: $current"
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
echo "Deleting existing release..."
curl -XDELETE $release_url -u $2
fi
else
echo "Wrong argument"
echo "Usage:"
echo " > ./github.sh del user:password"
exit
fi
;;
pre|rel)
if [[ $2 =~ ^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$ && $3 != "" ]]; then
if [[ $1 = "pre" ]]; then
prerelease="true"
else
prerelease="false"
fi
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
echo "Deleting existing release..."
curl -XDELETE $release_url -u $2
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 $upload_url
### Sending files
echo "Sending binaries..."
curl -i ''"$upload_url"'?name=cesium-v'"$current"'-web.zip' -u $2 -H 'Content-Type: application/zip' --data '@platforms/web/build/cesium-web-'"$current"'.zip'
curl -i ''"$upload_url"'?name=cesium-v'"$current"'-firefoxos.zip' -u $2 -H 'Content-Type: application/zip' --data '@platforms/firefoxos/build/package.zip'
curl -i ''"$upload_url"'?name=cesium-v'"$current"'-android.apk' -u $2 -H 'Content-Type: application/vnd.android.package-archive' --data '@platforms/android/build/outputs/apk/android-release.apk'
else
echo "Wrong arguments"
echo "Usage:"
echo " > ./github.sh pre|rel user:password <release_description>"
echo "With:"
echo " - pre: use for pre-release"
echo " - rel: for full release"
exit
fi
;;
*)
echo "No task given"
;;
esac
......@@ -16,7 +16,8 @@ currentAndroid=`grep -P "android-versionCode=\"\d+\"" config.xml | grep -oP "\d+
echo "Current Android version: $currentAndroid"
if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then
echo "build $2"
echo "new build version: $2"
echo "new build android version: $3"
case "$1" in
rel|pre)
# Change the version in package.json and test file
......@@ -41,10 +42,11 @@ if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ && $3 =~ ^[0-9]+$ ]]; then
esac
git commit -m "v$2"
git tag "v$2"
git push
else
echo "Wrong version format"
echo "Usage:"
echo " > release.sh [pre|rel] <version> <android-version>"
echo " > ./release.sh [pre|rel] <version> <android-version>"
echo "with:"
echo " - version: x.y.z"
echo " - android-version: nnn"
......@@ -62,3 +64,4 @@ gulp build:web --release
......@@ -28,8 +28,8 @@ angular.module("cesium.config", [])
"port": "9203"
}
},
"version": "0.2.3",
"build": "2016-08-23T09:25:41.250Z",
"version": "0.2.4",
"build": "2016-08-23T09:43:41.411Z",
"newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug"
})
......
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