Commit 4014b5e1 authored by PECQUOT's avatar PECQUOT

[enh] begin work on scripts

parent 48dd558f
......@@ -71,40 +71,10 @@ The application should be accessible at [localhost:4200](http://localhost:4200)
npm run build --prod --release
```
## Android build
### Build a debug APK, for development and test
1. Install the android build environment:
```bash
cd quadrige3-app/scripts
./env-android.sh
```
2. Create a debug APK file:
```bash
cd quadrige3-app/scripts
./build-android.sh
```
### Build a release APK, for production
1. Check environment configuration:
- Edit the file `src/environment/environment-prod.ts`
2. Create a release APK file:
```bash
cd quadrige3-app/scripts
./release-android.sh
```
## Useful links
- Ionic 4 colors: https://www.joshmorony.com/a-primer-on-css-4-variables-for-ionic-4/
- Migration to Ionic 4 tips: https://www.joshmorony.com/my-method-for-upgrading-from-ionic-3-to-ionic-4/
- Signing Android APK: See doc at
https://www.c-sharpcorner.com/article/create-ionic-4-release-build-for-android/
## Troubleshooting
......
#!/bin/bash
# Get to the root project
if [[ "_" == "_${PROJECT_DIR}" ]]; then
cd ..
PROJECT_DIR=`pwd`
export PROJECT_DIR
fi;
# Preparing Android environment
. ${PROJECT_DIR}/scripts/env-android.sh
[[ $? -ne 0 ]] && exit 1
cd ${PROJECT_DIR}
# Run the build
echo "Running cordova build..."
ionic cordova build android --warning-mode=none --color
#ionic cordova build android --warning-mode=none --color --verbose
......@@ -4,7 +4,7 @@ const { join } = require('path');
const { readdirSync, renameSync, readFileSync, copyFileSync } = require('fs');
const i18nDir = './www/assets/i18n/';
let pkgStr = readFileSync('./package.json', {encoding: 'UTF-8'});
const pkgStr = readFileSync('./package.json', {encoding: 'UTF-8'});
const pkg = JSON.parse(pkgStr);
console.debug('Insert version into I18n files...');
......
#!/bin/sh
PWD=`pwd`
CMD="sudo docker run -ti --rm -p 8100:8100 -p 35729:35729 -v $PWD:/quadrige3-app:rw quadrige3-app:release"
echo "Executing: CMD"
$CMD
#!/bin/bash
# Get to the root project
if [[ "_" == "_${PROJECT_DIR}" ]]; then
cd ..
PROJECT_DIR=`pwd`
export PROJECT_DIR
fi;
# Preparing Android environment
. ${PROJECT_DIR}/scripts/env-android.sh
[[ $? -ne 0 ]] && exit 1
cd ${PROJECT_DIR}
# Run the build
echo "Running Android emulator..."
ionic cordova emulate android --warning-mode=none --color
#!/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;
# Preparing environment
. ${PROJECT_DIR}/scripts/env-global.sh
[[ $? -ne 0 ]] && exit 1
if [[ "_" == "_${CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL}" ]]; then
echo "Missing Gradle distribution URL - please export env variable 'CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'"
exit 1
fi
echo "Preparing Android environment:"
echo " Root: ${PROJECT_DIR}"
echo " NodeJS: version ${NODE_VERSION} with options: ${NODE_OPTIONS}"
echo " Android SDK: ${ANDROID_SDK_ROOT} with SDK tools: ${ANDROID_SDK_TOOLS_ROOT}"
echo " Gradle: ${GRADLE_HOME}"
echo " Java: ${JAVA_HOME}"
# Make sure javac exists
JAVAC_PATH=$(which javac)
if [[ "_" == "_${JAVAC_PATH}" ]]; then
echo "ERROR: 'javac' executable not found in PATH. Make sure you have installed a complete Java JDK, and not only a JRE."
exit 1
fi
# Prepare Android SDK tools
if [[ ! -d "${ANDROID_SDK_TOOLS_ROOT}" ]]; then
cd "${PROJECT_DIR}/scripts"
./install-android-sdk-tools.sh
[[ $? -ne 0 ]] && exit 1
fi
# Install Gradle
if [[ "_" == "_$(which gradle)" && ! -d "${GRADLE_HOME}" ]]; then
cd "${PROJECT_DIR}/scripts"
echo "Installing gradle... ${GRADLE_HOME}"
test -e "gradle-${GRADLE_VERSION}-all.zip" || wget -kL ${CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL}
GRADLE_PARENT=$(dirname $GRADLE_HOME)
test -e "${GRADLE_PARENT}" || mkdir -p ${GRADLE_PARENT}
test -e "${GRADLE_PARENT}/gradle-${GRADLE_VERSION}" || unzip -qq gradle-${GRADLE_VERSION}-all.zip -d "${GRADLE_PARENT}"
[[ $? -ne 0 ]] && exit 1
test -e "${GRADLE_HOME}" || mv "${GRADLE_PARENT}/gradle-${GRADLE_VERSION}" "${GRADLE_HOME}"
[[ $? -ne 0 ]] && exit 1
test -e "${GRADLE_PARENT}/gradle-${GRADLE_VERSION}" || rm "${GRADLE_PARENT}/gradle-${GRADLE_VERSION}"
fi
# Prepare Android platform
if [[ ! -d "${PROJECT_DIR}/platforms/android" ]]; then
echo "Adding Cordova Android platform..."
cd "${PROJECT_DIR}"
ionic cordova prepare android --color --verbose
[[ $? -ne 0 ]] && exit 1
fi
# Copy local files
if [[ -d "${PROJECT_DIR}/.local/android" ]]; then
echo "Copying files from directory '${PROJECT_DIR}/.local/android' into '${PROJECT_DIR}/platforms/android'..."
cp -rf ${PROJECT_DIR}/.local/android/* ${PROJECT_DIR}/platforms/android
[[ $? -ne 0 ]] && exit 1
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!"
......@@ -17,15 +17,15 @@ NODE_VERSION=12
NODE_OPTIONS=--max-old-space-size=4096 # Avoid Javascript memory heap space
#ANDROID_NDK_VERSION=r19c
ANDROID_SDK_VERSION=r29.0.2
ANDROID_SDK_TOOLS_VERSION=6609375
ANDROID_SDK_ROOT=/usr/lib/android-sdk
ANDROID_ALTERNATIVE_SDK_ROOT="${HOME}/Android/Sdk"
ANDROID_SDK_TOOLS_ROOT=${ANDROID_SDK_ROOT}/cli
ANDROID_OUTPUT_APK=${PROJECT_DIR}/platforms/android/app/build/outputs/apk
ANDROID_OUTPUT_APK_DEBUG=${ANDROID_OUTPUT_APK}/debug
ANDROID_OUTPUT_APK_RELEASE=${ANDROID_OUTPUT_APK}/release
ANDROID_OUTPUT_APK_PREFIX=app
#ANDROID_SDK_VERSION=r29.0.2
#ANDROID_SDK_TOOLS_VERSION=6609375
#ANDROID_SDK_ROOT=/usr/lib/android-sdk
#ANDROID_ALTERNATIVE_SDK_ROOT="${HOME}/Android/Sdk"
#ANDROID_SDK_TOOLS_ROOT=${ANDROID_SDK_ROOT}/cli
#ANDROID_OUTPUT_APK=${PROJECT_DIR}/platforms/android/app/build/outputs/apk
#ANDROID_OUTPUT_APK_DEBUG=${ANDROID_OUTPUT_APK}/debug
#ANDROID_OUTPUT_APK_RELEASE=${ANDROID_OUTPUT_APK}/release
#ANDROID_OUTPUT_APK_PREFIX=app
PROJECT_NAME=quadrige3-app
......@@ -34,9 +34,9 @@ PROJECT_NAME=quadrige3-app
# /!\ WARN can be define in your <project>/.local/env.sh file
#JAVA_HOME=
GRADLE_VERSION=4.10.3
GRADLE_HOME=${HOME}/.gradle/${GRADLE_VERSION}
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip
#GRADLE_VERSION=4.10.3
#GRADLE_HOME=${HOME}/.gradle/${GRADLE_VERSION}
#CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip
# Override with a local file, if any
if [[ -f "${PROJECT_DIR}/.local/env.sh" ]]; then
......@@ -80,7 +80,8 @@ fi
#fi
# Add Java, Android SDK tools to path
PATH=${ANDROID_SDK_TOOLS_ROOT}/bin:${GRADLE_HOME}/bin:${JAVA_HOME}/bin$:$PATH
#PATH=${ANDROID_SDK_TOOLS_ROOT}/bin:${GRADLE_HOME}/bin:${JAVA_HOME}/bin$:$PATH
PATH=${JAVA_HOME}/bin$:$PATH
# Node JS (using nvm - Node Version Manager)
......@@ -117,9 +118,9 @@ export PATH \
JAVA_HOME \
NVM_DIR \
NODE_OPTIONS \
ANDROID_SDK_ROOT \
ANDROID_SDK_TOOLS_ROOT \
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
# ANDROID_SDK_ROOT \
# ANDROID_SDK_TOOLS_ROOT \
# CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
# Install global dependencies
IONIC_PATH=`which ionic`
......
#!/bin/bash
# Load global variables
. "$(dirname $0)/env-global.sh"
# Make sure variables are set
if [[ "_" == "_${ANDROID_SDK_ROOT}" ]]; then
echo "Please set env variable ANDROID_SDK_ROOT"
exit 1
fi
if [[ "_" == "_${ANDROID_SDK_TOOLS_ROOT}" ]]; then
echo "Please set env variable ANDROID_SDK_TOOLS_ROOT"
exit 1
fi
if [[ ! -d "${ANDROID_SDK_TOOLS_ROOT}/tools/bin" ]]; then
echo "Installing Android SDK CLI tools... ${ANDROID_SDK_TOOLS_ROOT}"
ANDROID_SDK_CLI_TOOL_FILE="commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip"
test -e "${ANDROID_SDK_CLI_TOOL_FILE}" || wget -kL https://dl.google.com/android/repository/${ANDROID_SDK_CLI_TOOL_FILE}
# Get parent folder
test -e "${ANDROID_SDK_TOOLS_ROOT}" || mkdir -p "${ANDROID_SDK_TOOLS_ROOT}"
test -e "${ANDROID_SDK_TOOLS_ROOT}" && unzip -qq ${ANDROID_SDK_CLI_TOOL_FILE} -d "${ANDROID_SDK_TOOLS_ROOT}"
test -e "${ANDROID_SDK_TOOLS_ROOT}" && rm "${ANDROID_SDK_CLI_TOOL_FILE}"
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 -E ./install-android-sdk-tools.sh\`"
exit 1
fi
export PATH=${ANDROID_SDK_TOOLS_ROOT}/tools/bin:$PATH
mkdir -p ${ANDROID_SDK_ROOT}/licenses
echo 8933bad161af4178b1185d1a37fbf41ea5269c55 > ${ANDROID_SDK_ROOT}/licenses/android-sdk-license
echo 601085b94cd77f0b54ff86406957099ebe79c4d6 > ${ANDROID_SDK_ROOT}/licenses/android-googletv-license
echo 33b6a2b64607f11b759f320ef9dff4ae5c47d97a > ${ANDROID_SDK_ROOT}/licenses/google-gdk-license
yes | sdkmanager --licenses "--sdk_root=${ANDROID_SDK_ROOT}"
mkdir -p ~/.android
touch ~/.android/repositories.cfg
echo y | sdkmanager "platform-tools" "--sdk_root=${ANDROID_SDK_ROOT}" | tee sdkmanager.log
echo y | sdkmanager "extras;android;m2repository" "--sdk_root=${ANDROID_SDK_ROOT}" | tee -a sdkmanager.log
echo y | sdkmanager "extras;google;m2repository" "--sdk_root=${ANDROID_SDK_ROOT}" | tee -a sdkmanager.log
# Install build tools
echo y | sdkmanager "build-tools;23.0.2" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "build-tools;23.0.3" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "build-tools;25.0.2" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "build-tools;27.0.3" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "build-tools;28.0.3" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "build-tools;29.0.2" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
# Install platforms
echo y | sdkmanager "platforms;android-16" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "platforms;android-21" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "platforms;android-23" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "platforms;android-24" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "platforms;android-25" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "platforms;android-27" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "platforms;android-28" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
echo y | sdkmanager "platforms;android-29" --sdk_root=${ANDROID_SDK_ROOT} | tee -a sdkmanager.log
#!/bin/bash
# Get to the root project
if [[ "_" == "_${PROJECT_DIR}" ]]; then
cd ..
PROJECT_DIR=`pwd`
export PROJECT_DIR
fi;
# Preparing Android environment
. ${PROJECT_DIR}/scripts/env-android.sh
[[ $? -ne 0 ]] && exit 1
cd ${PROJECT_DIR}
# Run the build
echo "Running cordova build..."
ionic cordova build android --prod --release --warning-mode=none --color
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/quadrige3.keystore
KEY_ALIAS=quadrige3
KEY_PWD=
APK_DIR=${PROJECT_DIR}/platforms/android/app/build/outputs/apk/release
APK_UNSIGNED_FILE=${APK_DIR}/app-release.apk
BUILD_TOOLS_DIR="${ANDROID_SDK_ROOT}/build-tools/28.*/"
if [[ ! -f "${APK_UNSIGNED_FILE}" ]]; then
echo "APK file not found at: ${APK_UNSIGNED_FILE}"
exit 1
fi
# Check if signed
cd ${BUILD_TOOLS_DIR}
./apksigner verify ${APK_UNSIGNED_FILE}
# Not signed ? Do it !
if [[ $? -ne 0 ]]; then
echo "It seems that the APK file ${APK_UNSIGNED_FILE} is not signed !"
if [[ ! -f "${KEYSTORE_FILE}" ]]; then
echo "ERROR: Unable to sign: no keystore file found at ${KEYSTORE_FILE} !"
exit 1
fi
echo "Signing APK file ${APK_UNSIGNED_FILE}..."
APK_SIGNED_FILE=${APK_DIR}/app-release-signed.apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ${KEYSTORE_FILE} ${APK_UNSIGNED_FILE} quadrige3
BUILD_TOOLS_DIR="${ANDROID_SDK_ROOT}/build-tools/28.*/"
cd ${BUILD_TOOLS_DIR}
./zipalign -v 4 ${APK_UNSIGNED_FILE} ${APK_SIGNED_FILE}
./apksigner verify ${APK_SIGNED_FILE}
if [[ $? -ne 0 ]]; then
echo "Signing failed !"
exit 1
fi
# Do file replacement
rm ${APK_UNSIGNED_FILE}
mv ${APK_SIGNED_FILE} ${APK_UNSIGNED_FILE}
fi
......@@ -9,7 +9,7 @@ fi;
task=$1
# Preparing Android environment
# Preparing environment
cd ${PROJECT_DIR}
source ${PROJECT_DIR}/scripts/env-global.sh
......@@ -32,29 +32,28 @@ echo "Current version: $current"
### Get repo URL
PROJECT_NAME=quadrige3-app
REMOTE_URL=`git remote -v | grep -P "push" | grep -oP "(https:\/\/github.com\/|git@github.com:)[^ ]+"`
REPO="quadrige3-net/quadrige3-app"
REPO_API_URL=https://api.github.com/repos/$REPO
REPO_PUBLIC_URL=https://github.com/$REPO
REMOTE_URL=`git remote -v | grep -P "push" | grep -oP "(https:\/\/gitlab.ifremer.fr\/|git@gitlab.ifremer.fr:)[^ ]+"`
REPO="quadrige/quadrige3-app"
REPO_API_URL=https://gitlab.ifremer.fr/api/v4/projects/quadrige%2Fquadrige3-app
REPO_PUBLIC_URL=https://gitlab.ifremer.fr/$REPO
### get auth token
GITHUB_TOKEN=`cat ~/.config/${PROJECT_NAME}/.github`
if [[ "_$GITHUB_TOKEN" != "_" ]]; then
GITHUT_AUTH="Authorization: token $GITHUB_TOKEN"
GITLAB_TOKEN=`cat ~/.config/${PROJECT_NAME}/.gitlab`
if [[ "_$GITLAB_TOKEN" != "_" ]]; then
GITLAB_AUTH="Authorization: Bearer $GITLAB_TOKEN"
else
echo "ERROR: Unable to find github authentication 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/${PROJECT_NAME}/.github' using a valid token."
echo "ERROR: Unable to find gitlab authentication token file: "
echo " - You can create such a token at https://gitlab.ifremer.fr/quadrige/quadrige3-app/-/settings/access_tokens"
echo " - Then copy the token and paste it in the file '~/.config/${PROJECT_NAME}/.gitlab' using a valid token"
exit 1
fi
case "$task" in
del)
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
result=`curl --header ''"$GITLAB_AUTH"'' "$REPO_API_URL/releases/$current" -o /dev/null -s -w "%{http_code}\n"`
if [[ $result = 200 ]]; then
echo "Deleting existing release..."
curl -H ''"$GITHUT_AUTH"'' -XDELETE $release_url
curl --header ''"$GITLAB_AUTH"'' "$REPO_API_URL/releases/$current" --request DELETE
fi
;;
......@@ -71,11 +70,11 @@ case "$task" in
description="Release $current"
fi
result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_API_URL/releases/tags/$current"`
result=`curl -s -H ''"$GITLAB_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"
result=`curl -H ''"$GITHUT_AUTH"'' -s -XDELETE $release_url`
result=`curl -H ''"$GITLAB_AUTH"'' -s -XDELETE $release_url`
if [[ "_$result" != "_" ]]; then
error_message=`echo "$result" | grep -P "\"message\": \"[^\"]+" | grep -oP ": \"[^\"]+\""`
echo "Delete existing release failed with error $error_message"
......@@ -88,7 +87,7 @@ case "$task" in
echo "Creating new release..."
echo " - tag: $current"
echo " - description: $description"
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"'}'`
result=`curl -H ''"$GITLAB_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
......@@ -105,12 +104,12 @@ case "$task" in
ZIP_FILE="${DIRNAME}/dist/${PROJECT_NAME}.zip"
if [[ -f "${ZIP_FILE}" ]]; then
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}")
result=$(curl -s -H ''"$GITLAB_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}" | 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")
result=$(curl -s -H ''"$GITLAB_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."
missing_file=true
......@@ -119,12 +118,12 @@ case "$task" in
APK_FILE="${DIRNAME}/platforms/android/app/build/outputs/apk/release/app-release.apk"
if [[ -f "${APK_FILE}" ]]; then
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}")
result=$(curl -s -H ''"$GITLAB_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}" | 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")
result=$(curl -s -H ''"$GITLAB_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."
missing_file=true
......
......@@ -7,27 +7,39 @@ if [[ "_" == "_${PROJECT_DIR}" ]]; then
fi;
# Preparing Android environment
. ${PROJECT_DIR}/scripts/env-android.sh
[[ $? -ne 0 ]] && exit 1
#. ${PROJECT_DIR}/scripts/env-android.sh
#[[ $? -ne 0 ]] && exit 1
cd ${PROJECT_DIR}
# Read parameters
task=$1
version=$2
androidVersion=$3
#androidVersion=$3
release_description=$4
# Check version format
if [[ ! $task =~ ^(pre|rel)$ || ! $version =~ ^[0-9]+.[0-9]+.[0-9]+(-(alpha|beta|rc)[0-9]+)?$ || ! $androidVersion =~ ^[0-9]+$ ]]; then
#if [[ ! $task =~ ^(pre|rel)$ || ! $version =~ ^[0-9]+.[0-9]+.[0-9]+(-(alpha|beta|rc)[0-9]+)?$ || ! $androidVersion =~ ^[0-9]+$ ]]; then
#if [[ ! $task =~ ^(pre|rel)$ || ! $version =~ ^[0-9]+.[0-9]+.[0-9]+(-(alpha|beta|rc)[0-9]+)?$ ]]; then
# echo "Wrong version format"
# echo "Usage:"
# echo " > ./release-gitflow.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
if [[ ! $task =~ ^(pre|rel)$ || ! $version =~ ^[0-9]+.[0-9]+.[0-9]+(-(alpha|beta|rc)[0-9]+)?$ ]]; then
echo "Wrong version format"
echo "Usage:"
echo " > ./release-gitflow.sh [pre|rel] <version> <android-version> <release_description>"
echo " > ./release.sh [pre|rel] <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
......@@ -58,12 +70,12 @@ fi
echo "Current version: $current"
### Get current version for Android
currentAndroid=`grep -oP "android-versionCode=\"[0-9]+\"" config.xml | grep -oP "\d+"`
if [[ "_$currentAndroid" == "_" ]]; then
echo ">> Unable to read the current Android version in 'config.xml'. Please check version format is an integer."
exit 1;
fi
echo "Current Android version: $currentAndroid"
#currentAndroid=`grep -oP "android-versionCode=\"[0-9]+\"" config.xml | grep -oP "\d+"`
#if [[ "_$currentAndroid" == "_" ]]; then
# echo ">> Unable to read the current Android version in 'config.xml'. Please check version format is an integer."
# exit 1;
#fi
#echo "Current Android version: $currentAndroid"
echo "**********************************"
if [[ $resumeRelease = 0 ]]
......@@ -74,7 +86,7 @@ else
fi
echo "**********************************"
echo "* new build version: $version"
echo "* new build android version: $androidVersion"
#echo "* new build android version: $androidVersion"
echo "**********************************"
if [[ $resumeRelease = 0 ]]
......@@ -92,7 +104,7 @@ rel|pre)
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
# 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+(-(alpha|beta|rc)[0-9]+)?\"" src/assets/manifest.json | grep -oP "\d+.\d+.\d+(-(alpha|beta|rc)[0-9]+)?"`
......@@ -127,21 +139,21 @@ if [[ $? -ne 0 ]]; then
exit 1
fi
echo "-------------------------------------------"
echo "- Compiling sources for Android platform..."
echo "-------------------------------------------"
#echo "-------------------------------------------"
#echo "- Compiling sources for Android platform..."
#echo "-------------------------------------------"
# Removing previous APK..."
rm ${PROJECT_DIR}/platforms/android/app/build/outputs/apk/release/*.apk
#rm ${PROJECT_DIR}/platforms/android/app/build/outputs/apk/release/*.apk
# Copy generated i18n files, to make sure Android release will use it
cp ${PROJECT_DIR}/www/assets/i18n/*.json ${PROJECT_DIR}/src/assets/i18n/
#cp ${PROJECT_DIR}/www/assets/i18n/*.json ${PROJECT_DIR}/src/assets/i18n/
# Launch the build script
PROJECT_DIR=${PROJECT_DIR}
cd ${PROJECT_DIR}/scripts || exit 1
./release-android.sh
[[ $? -ne 0 ]] && exit 1
#PROJECT_DIR=${PROJECT_DIR}
#cd ${PROJECT_DIR}/scripts || exit 1
#./release-android.sh
#[[ $? -ne 0 ]] && exit 1
description="$release_description"
if [[ "_$description" == "_" ]]; then
......@@ -164,7 +176,7 @@ echo "**********************************"
echo "* Uploading artifacts to Github..."
echo "**********************************"
cd $PROJECT_DIR/scripts
./release-to-github.sh "$task" ''"$description"''
./release-to-gitlab.sh "$task" ''"$description"''
[[ $? -ne 0 ]] && exit 1
#echo "----------------------------------"
......
#!/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;
# Preparing Android environment
. ${PROJECT_DIR}/scripts/env-android.sh
[[ $? -ne 0 ]] && exit 1
cd ${PROJECT_DIR}
# Run the build
echo "Building Android application..."
ionic cordova build android --warning-mode=none --color $*
[[ $? -ne 0 ]] && exit 1