From c3e66452beff5cde65aae734dd3ab1a19c51e1b0 Mon Sep 17 00:00:00 2001 From: Benoit Lavenier <benoit.lavenier@e-is.pro> Date: Thu, 11 May 2023 18:19:27 +0200 Subject: [PATCH] [fix] Fix release scripts --- doc/build_web_extension.md | 2 +- doc/development_guide.md | 12 ++++++------ resources/android/Dockerfile | 2 +- scripts/env-global.sh | 6 +++--- scripts/release-android.sh | 3 ++- scripts/release-sign-extension.sh | 17 +++++++++-------- scripts/release.sh | 9 +++++---- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/doc/build_web_extension.md b/doc/build_web_extension.md index 5fe85e0ba..d77955738 100644 --- a/doc/build_web_extension.md +++ b/doc/build_web_extension.md @@ -8,7 +8,7 @@ Cesium can be build as Web extension, for Mozilla Firefox extension (`.xpi`) and Follow all the steps defined in the [Development guide](./development_guide.md). -After that you should be able to start the application using `npm start`or `yarn run start`, and to test it. +After that you should be able to start the application using `yarn run start`, and to test it. ## Build the web extension diff --git a/doc/development_guide.md b/doc/development_guide.md index d42b29bf6..b47b8ad3c 100644 --- a/doc/development_guide.md +++ b/doc/development_guide.md @@ -3,8 +3,8 @@ ## In a post-it ```bash -# Install NodeJS v12 -nvm use 12 +# Install NodeJS v16 +nvm use 16 npm install -g yarn # Clone and compile from source @@ -28,7 +28,7 @@ To build Cesium, you will have to: sudo apt-get install git wget curl unzip build-essential software-properties-common ruby ruby-dev ruby-ffi gcc make ``` -2. Installing node.js v12 : +2. Installing node.js v16 : * First, install [nvm](https://github.com/nvm-sh/nvm) (Node Version Manager) : ```bash @@ -41,7 +41,7 @@ To build Cesium, you will have to: * Configure nvm to use the expected version: (**WARNING**: upper version will NOT work !) ```bash - nvm install 12 + nvm install 16 ``` 3. Installing node build tools, as global dependencies: @@ -64,7 +64,7 @@ To build Cesium, you will have to: 3. Installing Cordova plugins (required to build Android and iOS artifacts): ```bash - export JAVA_HOME=/path/to/jdk-8 + export JAVA_HOME=/path/to/jdk-11 export PATH=$JAVA_HOME/bin:$PATH ionic cordova prepare ``` @@ -73,7 +73,7 @@ To build Cesium, you will have to: > As a reminder: check that your command line is well configured: > - You must place yourself in the directory of the application: `cd cesium` - > - and working with NodeJs **v12**: `nvm use 12` (please check using the command `node --version`) + > - and working with NodeJs **v16**: `nvm use 16` (please check using the command `node --version`) ### Prepare configuration file diff --git a/resources/android/Dockerfile b/resources/android/Dockerfile index 4acd3b844..eaebcec41 100644 --- a/resources/android/Dockerfile +++ b/resources/android/Dockerfile @@ -36,7 +36,7 @@ RUN npm install -g cordova@"$CORDOVA_VERSION" cordova-res@"$CORDOVA_RES_VERSION" RUN echo ANDROID_HOME="${ANDROID_HOME}" >> /etc/environment && \ dpkg --add-architecture i386 && \ apt-get update && \ - apt-get -y install openjdk-8-jdk-headless && \ + apt-get -y install openjdk-11-jdk-headless && \ apt-get install -y --force-yes expect ant wget zipalign libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1 qemu-kvm kmod && \ apt-get clean && \ apt-get autoclean && \ diff --git a/scripts/env-global.sh b/scripts/env-global.sh index c5cd614ad..4da919fdf 100755 --- a/scripts/env-global.sh +++ b/scripts/env-global.sh @@ -42,7 +42,7 @@ DIST_WEB=${PROJECT_DIR}/dist/web/build DIST_ANDROID=${PROJECT_DIR}/dist/android # Addons Mozilla Web extension ID -WEB_EXT_ID="{6f9922f7-a054-4609-94ce-d269993246a5}" +WEB_EXT_ID=${WEB_EXT_ID:-"{6f9922f7-a054-4609-94ce-d269993246a5}"} # /!\ WARN can be define in your <project>/.local/env.sh file #JAVA_HOME= @@ -121,7 +121,7 @@ else fi # Checking if some global dependencies are missing -GLOBAL_TOOLS="yarn ionic cordova cordova-res native-run web-ext" +GLOBAL_TOOLS="yarn gulp ionic cordova web-ext cordova-res native-run" MISSING_GLOBAL_TOOLS= for GLOBAL_TOOL in ${GLOBAL_TOOLS} do @@ -135,7 +135,7 @@ done # Install global dependencies if ! test -z "${MISSING_GLOBAL_TOOLS}"; then echo "Installing global dependencies..." - npm install -g yarn cordova cordova-res @ionic/cli@$IONIC_CLI_VERSION web-ext native-run + npm install -g yarn gulp cordova @ionic/cli@$IONIC_CLI_VERSION web-ext cordova-res native-run if ! test $? == 0; then echo "ERROR: Unable to install global dependencies" #exit 1 diff --git a/scripts/release-android.sh b/scripts/release-android.sh index 0cfceeeb3..c75b88845 100755 --- a/scripts/release-android.sh +++ b/scripts/release-android.sh @@ -13,7 +13,8 @@ KEY_ALIAS=Cesium KEY_PWD= # Preparing Android environment -source ${PROJECT_DIR}/scripts/env-android.sh +cd ${PROJECT_DIR} +source scripts/env-android.sh [[ $? -ne 0 ]] && exit 1 APK_SIGNED_FILE=${ANDROID_OUTPUT_APK_RELEASE}/${ANDROID_OUTPUT_APK_PREFIX}-release-signed.apk diff --git a/scripts/release-sign-extension.sh b/scripts/release-sign-extension.sh index b5c533dd1..8b6bb42e2 100755 --- a/scripts/release-sign-extension.sh +++ b/scripts/release-sign-extension.sh @@ -9,12 +9,7 @@ fi; # Preparing Android environment cd ${PROJECT_DIR} -source ${PROJECT_DIR}/scripts/env-global.sh - -XPI_BASENAME=${PROJECT_NAME}-$current-an+fx.xpi -XPI_FILE=${PROJECT_DIR}/dist/web/build/${XPI_BASENAME} -XPI_FINAL_BASENAME=${PROJECT_NAME}-v$current-extension-firefox.xpi -XPI_FINAL_FILE=${PROJECT_DIR}/dist/web/build/${XPI_FINAL_BASENAME} +source scripts/env-global.sh ### Control that the script is run on `dev` branch branch=$(git rev-parse --abbrev-ref HEAD) @@ -25,16 +20,21 @@ then 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 -m 1 -oP "version\": \"\d+.\d+.\d+(-\w+[0-9]*)?" package.json | grep -m 1 -oP "\d+.\d+.\d+(-\w+[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; fi echo "Sending v$current extension for Mozilla..." +XPI_BASENAME=${PROJECT_NAME}-$current-an+fx.xpi +XPI_FILE=${PROJECT_DIR}/dist/web/build/${XPI_BASENAME} +XPI_FINAL_BASENAME=${PROJECT_NAME}-v$current-extension-firefox.xpi +XPI_FINAL_FILE=${PROJECT_DIR}/dist/web/build/${XPI_FINAL_BASENAME} + ### Check AMO account if [[ "_" == "_${AMO_JWT_ISSUER}" || "_" == "_${AMO_JWT_SECRET}" ]]; then - echo "ERROR: Unable to find Addons Modzilla account: " + echo "ERROR: Unable to find Addons Mozilla account: " echo " - Please add environment variables 'AMO_JWT_ISSUER' or 'AMO_JWT_SECRET', then retry." echo " - You can use the file './local/env.sh'." exit 1 @@ -43,6 +43,7 @@ fi ### Sign extension case "$1" in pre) + echo "web-ext sign \"--api-key=${AMO_JWT_ISSUER}\" \"--api-secret=${AMO_JWT_SECRET}\" \"--source-dir=${PROJECT_DIR}/dist/web/ext\" \"--artifacts-dir=${PROJECT_DIR}/dist/web/build\" --id=${WEB_EXT_ID} --channel=unlisted" web-ext sign "--api-key=${AMO_JWT_ISSUER}" "--api-secret=${AMO_JWT_SECRET}" "--source-dir=${PROJECT_DIR}/dist/web/ext" "--artifacts-dir=${PROJECT_DIR}/dist/web/build" --id=${WEB_EXT_ID} --channel=unlisted if [[ $? -ne 0 ]]; then if [[ -f "${XPI_FILE}" || -f "${XPI_FINAL_FILE}" ]]; then diff --git a/scripts/release.sh b/scripts/release.sh index ab76b39b2..47c202e11 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -53,16 +53,16 @@ case "$1" 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]+)?") + currentConfigXmlVersion=$(grep -m 1 -oP "version=\"\d+.\d+.\d+(-\w+[0-9]*)?\"" config.xml | grep -oP "\d+.\d+.\d+(-\w+[0-9]*)?") sed -i "s/ version=\"$currentConfigXmlVersion\"/ version=\"$2\"/g" config.xml sed -i "s/ android-versionCode=\"$currentAndroid\"/ android-versionCode=\"$3\"/g" config.xml # Change version in file: 'www/manifest.json' - currentManifestJsonVersion=$(grep -oP "version\": \"\d+.\d+.\d+((a|b)[0-9]+)?\"" www/manifest.json | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?") + currentManifestJsonVersion=$(grep -m 1 -oP "version\": \"\d+.\d+.\d+(-\w+[0-9]*)?\"" www/manifest.json | grep -oP "\d+.\d+.\d+(-\w+[0-9]*)?") sed -i "s/version\": \"$currentManifestJsonVersion\"/version\": \"$2\"/g" www/manifest.json # Change version in file: 'resources/web-ext/manifest.json' - currentExtManifestJsonVersion=$(grep -oP "version\": \"\d+.\d+.\d+((a|b)[0-9]+)?\"" resources/web-ext/manifest.json | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?") + currentExtManifestJsonVersion=$(grep -m 1 -oP "version\": \"\d+.\d+.\d+(-\w+[0-9]*)?\"" resources/web-ext/manifest.json | grep -oP "\d+.\d+.\d+(-\w+[0-9]*)?") sed -i "s/version\": \"$currentExtManifestJsonVersion\"/version\": \"$2\"/g" resources/web-ext/manifest.json # Bump the install.sh @@ -149,7 +149,8 @@ git push -f origin echo "----------------------------------" echo "- Uploading web extension to Mozilla ..." echo "----------------------------------" -. ${PROJECT_DIR}/scripts/release-sign-extension.sh $1 +cd ${PROJECT_DIR}/scripts || exit 1 +./release-sign-extension.sh $1 ''"$description"'' # FIXME: always failed, but continue #[[ $? -ne 0 ]] && exit 1 -- GitLab