Commit 2627e853 authored by PECQUOT's avatar PECQUOT
Browse files

[fix] update scripts

parents 6cbeca34 330bacc8
*.sh text eol=lf
\ No newline at end of file
......@@ -37,3 +37,4 @@ Thumbs.db
UserInterfaceState.xcuserstate
yarn.lock
resources/android/build/local
package-lock.json
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="10304" id="net.sumaris.app" version="1.3.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-versionCode="10305" id="net.sumaris.app" version="1.3.5-alpha1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SUMARiS</name>
<description>Halieutic data capture</description>
<author email="contact@e-is.pro" href="http://www.e-is.pro">Environmental Information Systems</author>
......
......@@ -2,14 +2,14 @@
### Control that the script is run on `dev` branch
branch=`git rev-parse --abbrev-ref HEAD`
if [[ ! "$branch" = "master" ]] && [[ ! "$branch" =~ ^release/[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ ]];
if [[ ! "$branch" = "master" ]] && [[ ! "$branch" =~ ^release/[0-9]+.[0-9]+.[0-9]+(-(alpha|beta|rc)[0-9]+)?$ ]];
then
echo ">> This script must be run under \`master\` or a \`release\` branch"
exit 1
fi
### Get version to release
current=`grep -P "version\": \"\d+.\d+.\d+(\w*)" package.json | grep -m 1 -oP "\d+.\d+.\d+(\w*)"`
current=`grep -P "version\": \"\d+.\d+.\d+(-(\w+)[0-9]+)" package.json | grep -m 1 -oP "\d+.\d+.\d+(-(\w+)[0-9]+)"`
if [[ "_$version" != "_" ]]; then
echo "ERROR: Unable to read 'version' in the file 'package.json'."
echo " - Make sure the file 'package.json' exists and is readable."
......@@ -37,7 +37,7 @@ fi
case "$1" in
del)
result=`curl -i "$REPO_API_URL/releases/tags/v$current"`
result=`curl -i "$REPO_API_URL/releases/tags/$current"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "$REPO_API_URL/releases/\d+"`
if [[ $release_url != "" ]]; then
echo "Deleting existing release..."
......@@ -56,10 +56,10 @@ case "$1" in
description=`echo $2`
if [[ "_$description" = "_" ]]; then
description="Release v$current"
description="Release $current"
fi
result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_API_URL/releases/tags/v$current"`
result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_API_URL/releases/tags/$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"
......@@ -74,9 +74,9 @@ case "$1" in
fi
echo "Creating new release..."
echo " - tag: v$current"
echo " - tag: $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"'}'`
result=`curl -H ''"$GITHUT_AUTH"'' -s $REPO_API_URL/releases -d '{"tag_name": "'"$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/.-]+"`
if [[ "_$upload_url" = "_" ]]; then
......@@ -92,27 +92,33 @@ case "$1" in
ZIP_FILE="$DIRNAME/dist/${PROJECT_NAME}.zip"
if [[ -f "${ZIP_FILE}" ]]; then
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${ZIP_FILE}" "${upload_url}?name=${PROJECT_NAME}-v${current}-web.zip")
artifact_name="${PROJECT_NAME}-${current}-web.zip"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${ZIP_FILE}" "${upload_url}?name=${artifact_name}")
browser_download_url=$(echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+")
ZIP_SHA256=$(sha256sum "${ZIP_FILE}")
ZIP_SHA256=$(sha256sum "${ZIP_FILE}" | sed 's/ /\n/gi' | head -n 1)
echo " - ${browser_download_url} | SHA256 Checksum: ${ZIP_SHA256}"
echo "${ZIP_SHA256} ${artifact_name}" > "${ZIP_FILE}.sha256"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: text/plain' -T "${ZIP_FILE}.sha256" "${upload_url}?name=${artifact_name}.sha256")
else
echo " - ERROR: Web release (ZIP) not found! Skipping."
fi
APK_FILE="${DIRNAME}/platforms/android/app/build/outputs/apk/release/app-release.apk"
if [[ -f "${APK_FILE}" ]]; then
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/vnd.android.package-archive' -T "${APK_FILE}" "${upload_url}?name=${PROJECT_NAME}-v${current}-android.apk")
artifact_name="${PROJECT_NAME}-${current}-android.apk"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/vnd.android.package-archive' -T "${APK_FILE}" "${upload_url}?name=${artifact_name}")
browser_download_url=$(echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+")
APK_SHA256=$(sha256sum "${APK_FILE}")
APK_SHA256=$(sha256sum "${APK_FILE}" | sed 's/ /\n/gi' | head -n 1)
echo " - ${browser_download_url} | SHA256 Checksum: ${APK_SHA256}"
echo "${APK_SHA256} ${artifact_name}" > "${APK_FILE}.sha256"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: text/plain' -T "${APK_FILE}.sha256" "${upload_url}?name=${artifact_name}.sha256")
else
echo "- ERROR: Android release (APK) not found! Skipping."
fi
echo "-----------------------------------------"
echo "Successfully uploading files !"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/v${current}"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/${current}"
exit 0
else
echo "Wrong arguments"
......
......@@ -15,7 +15,7 @@ if [[ "_$INSTALL_DIR" == "_" ]]; then
fi
latest_version() {
echo "v1.3.4" #lastest
echo "1.3.5-alpha1" #lastest
}
api_release_url() {
......@@ -48,7 +48,7 @@ install_from_github() {
echo "WARNING: Deleting existing archive [$ARCHIVE_FILE]"
rm ${ARCHIVE_FILE}
fi
else
mkdir -p "$INSTALL_DIR"
fi
......
This diff is collapsed.
{
"name": "sumaris-app",
"description": "SUMARiS app",
"version": "1.3.4",
"version": "1.3.5-alpha1",
"author": "contact@e-is.pro",
"license": "AGPL-3.0",
"readmeFilename": "README.md",
......@@ -192,4 +192,4 @@
"node": ">= 10.20.0",
"npm": ">= 6.14.4"
}
}
\ No newline at end of file
}
......@@ -69,4 +69,9 @@ else
echo "No directory '${PROJECT_DIR}/.local/android' found. Please create it, with a file 'release-signing.properties' for release signing"
fi
echo
echo "Check Requirements"
cordova requirements android --verbose
[[ $? -ne 0 ]] && exit 1
echo "Android environment is ready!"
......@@ -24,7 +24,7 @@ if [[ ! -d "${ANDROID_SDK_TOOLS_ROOT}/tools/bin" ]]; then
fi
if [[ ! -d "${ANDROID_SDK_TOOLS_ROOT}/tools/bin" ]]; then
echo "Failed to install Android SDK CLI tools. If you are not root, try with sudo..."
echo "Failed to install Android SDK CLI tools. If you are not root, try with \`sudo -E ./install-android-sdk-tools.sh\`"
exit 1
fi
......
......@@ -18,7 +18,10 @@ cd ${PROJECT_DIR}
echo "Running cordova build..."
ionic cordova build android --prod --release --warning-mode=none --color
[[ $? -ne 0 ]] && exit 1
if [[ $? -ne 0 ]]; then
echo "Something's wrong with your environment. Please check if you have permissions on ~/.android"
exit 1
fi
# Signature
KEYSTORE_FILE=${PROJECT_DIR}/.local/android/Sumaris.keystore
......
#!/bin/bash
# Get to the root project
if [[ "_" == "_${PROJECT_DIR}" ]]; then
SCRIPT_DIR=$(dirname $0)
PROJECT_DIR=$(cd "${SCRIPT_DIR}/.." && pwd)
export PROJECT_DIR
fi;
cd ${PROJECT_DIR}
# Read parameters
version=$1
release_description=$2
PROJECT_DIR=`pwd`
# Check version format
if [[ ! $version =~ ^[0-9]+.[0-9]+.[0-9]+(-(alpha|beta|rc)[0-9]+)?$ ]]; then
echo "Wrong version format"
echo "Usage:"
echo " > ./release-gitflow-finish.sh <version> <release_description>"
echo "with:"
echo " - version: x.y.z"
echo " - release_description: a comment on release"
exit 1
fi
### Control that the script is run on `release` branch
branch=`git rev-parse --abbrev-ref HEAD`
if [[ ! "$branch" = "release/$version" ]]
then
echo ">> This script must be run under \`develop\` or \`release/$version\` branch"
exit 1
fi
description="Release $version"
if [[ ! "_$release_description" == "_" ]]; then
description="$description : $release_description"
fi
# finishing release
cd $PROJECT_DIR
rm src/assets/i18n/*-${version}.json
git add package.json src/assets/manifest.json config.xml install.sh
git commit -m "$description"
git flow release finish -F -p -n "$version"
if [[ $? -ne 0 ]]; then
exit 1
fi
......@@ -12,18 +12,23 @@ fi;
cd ${PROJECT_DIR}
# Read parameters
task=$1
version=$2
androidVersion=$3
release_description=$4
### Control that the script is run on `dev` branch
resumeRelease=0
branch=`git rev-parse --abbrev-ref HEAD`
if [[ ! "$branch" = "develop" ]]
then
if [[ "$branch" = "release/$2" ]]
if [[ "$branch" = "release/$version" ]]
then
echo "Resuming release ..."
resumeRelease=1
else
echo ">> This script must be run under \`develop\` or \`release/$2\` branch"
echo ">> This script must be run under \`develop\` or \`release/$version\` branch"
exit 1
fi
fi
......@@ -31,7 +36,7 @@ fi
PROJECT_DIR=`pwd`
### Get current version (package.json)
current=`grep -oP "version\": \"\d+.\d+.\d+((a|b)[0-9]+)?" package.json | grep -m 1 -oP "\d+.\d+.\d+((a|b)[0-9]+)?"`
current=`grep -oP "version\": \"\d+.\d+.\d+(-(alpha|beta|rc)[0-9]+)?" package.json | grep -m 1 -oP "\d+.\d+.\d+(-(alpha|beta|rc)[0-9]+)?"`
if [[ "_$current" == "_" ]]; then
echo ">> Unable to read the current version in 'package.json'. Please check version format is: x.y.z (x and y should be an integer)."
exit 1;
......@@ -47,10 +52,10 @@ 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
if [[ ! $task =~ ^(pre|rel)$ || ! $version =~ ^[0-9]+.[0-9]+.[0-9]+(-(alpha|beta|rc)[0-9]+)?$ || ! $androidVersion =~ ^[0-9]+$ ]]; then
echo "Wrong version format"
echo "Usage:"
echo " > ./release.sh [pre|rel] <version> <android-version> <release_description>"
echo " > ./release-gitflow.sh [pre|rel] <version> <android-version> <release_description>"
echo "with:"
echo " - pre: use for pre-release"
echo " - rel: for full release"
......@@ -68,32 +73,32 @@ else
echo "* Resuming release..."
fi
echo "**********************************"
echo "* new build version: $2"
echo "* new build android version: $3"
echo "* new build version: $version"
echo "* new build android version: $androidVersion"
echo "**********************************"
if [[ $resumeRelease = 0 ]]
then
git flow release start "$2"
git flow release start "$version"
if [[ $? -ne 0 ]]; then
exit 1
fi
fi
case "$1" in
case "$task" 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
sed -i "s/version\": \"$current\"/version\": \"$version\"/g" package.json
currentConfigXmlVersion=`grep -oP "version=\"\d+.\d+.\d+(-(alpha|beta|rc)[0-9]+)?\"" config.xml | grep -oP "\d+.\d+.\d+(-(alpha|beta|rc)[0-9]+)?"`
sed -i "s/ version=\"$currentConfigXmlVersion\"/ version=\"$version\"/g" config.xml
sed -i "s/ android-versionCode=\"$currentAndroid\"/ android-versionCode=\"$androidVersion\"/g" config.xml
# Change version in file: 'src/assets/manifest.json'
currentManifestJsonVersion=`grep -oP "version\": \"\d+.\d+.\d+((a|b)[0-9]+)?\"" src/assets/manifest.json | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?"`
sed -i "s/version\": \"$currentManifestJsonVersion\"/version\": \"$2\"/g" src/assets/manifest.json
currentManifestJsonVersion=`grep -oP "version\": \"\d+.\d+.\d+(-(alpha|beta|rc)[0-9]+)?\"" src/assets/manifest.json | grep -oP "\d+.\d+.\d+(-(alpha|beta|rc)[0-9]+)?"`
sed -i "s/version\": \"$currentManifestJsonVersion\"/version\": \"$version\"/g" src/assets/manifest.json
# Bump the install.sh
sed -i "s/echo \"v.*\" #lastest/echo \"v$2\" #lastest/g" install.sh
sed -i "s/echo \".*\" #lastest/echo \"$version\" #lastest/g" install.sh
;;
*)
echo "No task given"
......@@ -137,18 +142,18 @@ cd ${PROJECT_DIR}/scripts || exit 1
./release-android.sh
[[ $? -ne 0 ]] && exit 1
description="$4"
description="$release_description"
if [[ "_$description" == "_" ]]; then
description="Release v$2"
description="Release $version"
fi
# Commit
#cd $PROJECT_DIR
#git reset HEAD
#git add package.json config.xml src/assets/manifest.json install.sh
#git commit -m "v$2"
#git tag -f -a "v$2" -m "${description}"
#git push origin "v$2"
#git commit -m "$version"
#git tag -f -a "$version" -m "${description}"
#git push origin "$version"
#[[ $? -ne 0 ]] && exit 1
# Pause (if propagation is need between hosted git server and github)
......@@ -158,7 +163,7 @@ echo "**********************************"
echo "* Uploading artifacts to Github..."
echo "**********************************"
cd $PROJECT_DIR
./github.sh $1 ''"$description"''
./github.sh "$task" ''"$description"''
[[ $? -ne 0 ]] && exit 1
#echo "----------------------------------"
......@@ -173,7 +178,7 @@ cd $PROJECT_DIR
# cd platforms/desktop
# # Build desktop assets
# ./release.sh $2
# ./release.sh $version
# if [[ $? -ne 0 ]]; then
# exit 1
# fi
......@@ -181,21 +186,12 @@ cd $PROJECT_DIR
# echo "WARN: platform/desktop not found -> Skipping desktop build!"
#fi;
# back to nodejs version 6
#cd $PROJECT_DIR
#nvm use 10
echo "**********************************"
echo "* Finishing release"
echo "**********************************"
cd $PROJECT_DIR
rm "src/assets/i18n/*-$2.json"
git add package.json src/assets/manifest.json config.xml install.sh
git commit -m "$description"
git flow release finish "$2"
if [[ $? -ne 0 ]]; then
exit 1
fi
cd ${PROJECT_DIR}/scripts || exit 1
./release-gitflow-finish.sh "$version" ''"$release_description"''
[[ $? -ne 0 ]] && exit 1
echo "**********************************"
echo "* Build release succeed !"
......
......@@ -2,7 +2,7 @@
"name": "ADAP",
"short_name": "ADAP",
"manifest_version": 1,
"version": "1.3.4",
"version": "1.3.5-alpha1",
"default_locale": "fr",
"description": "ADAP App.",
"icons": [{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment