diff --git a/.gitignore b/.gitignore
index 9c54d3f7..5bd7c912 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,10 @@ build/config/buildinfo.properties
www-built
www-ghdeploy
+/node_modules/
+/tmp/
+/scripts/kiwix-*.pem
+/scripts/set_secret_environment_variables.sh
+/build/
+/scripts/travisci_builder_id_key
+/scripts/secret_files.tar.gz
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 989d4bc5..4e08f9a3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,20 @@
language: node_js
+node_js:
+ - "node"
addons:
sauce_connect:
- username: "kiwix"
+ username: kiwix
jwt:
- secure: "nOIQrCbKeAtX7GKqbW2O+Rhf4Fpg44Fjhk+3YHkFT6+663ATNRMZLDMqxrQURaf2CzbnTNzWDG8PWsI/nljA9tR4UEAt13xLEDpgF2lllfxP+DxdJdVH2tnPrpPautH0be1lzYD09n3+brdx2QoggA6/BUnxpS3nWaHK9e+lMGnUODB+Ybw8c3WwJha9zHPQ8h9LsFXj1Uc15K6rbUR8Dkdbh0P+prGnb8q02oNRTKBw5njIBJcZ111QuO/9FBo41+TAbQV619ezoe3yeUsVaaSNSdDYNr7Pkf+jtPGA+t1OgBJMSgz/KAydi6TNTeCb/vVtFS26TfJ+FBwJovDNXUgWHo0mrQjbyJ+WWCYjNCLTWZWqdEDzLFJ5tOO6by+S3ZBplLo+6r0pCTcv9/VLML3Kl/0g06aKIF65askmIGBVMafkRX/QYuXTKHGHduxzhUNO2ENgU2A3XihWEf3kbygQUWUpBJ9ktcjhdbM5ZdIzRorcsHOOzCm6qex+l1zJQb8V5CK2B3VqCYeiq/uE0R44ZNSxfpbUKkAGcGokY5B5lPVMWVzAuNyuXdGGV3XFwuYQULlPJLN8OKQjF24f8IOcKsLHu+k06blY8SiE2o8tI9r2IDqGY5QjrLaW4OAytwsAmK2cYqTZmxk8IwQ6UyyChEpAItnlJS84Wuya5I8="
-
+ secure: nOIQrCbKeAtX7GKqbW2O+Rhf4Fpg44Fjhk+3YHkFT6+663ATNRMZLDMqxrQURaf2CzbnTNzWDG8PWsI/nljA9tR4UEAt13xLEDpgF2lllfxP+DxdJdVH2tnPrpPautH0be1lzYD09n3+brdx2QoggA6/BUnxpS3nWaHK9e+lMGnUODB+Ybw8c3WwJha9zHPQ8h9LsFXj1Uc15K6rbUR8Dkdbh0P+prGnb8q02oNRTKBw5njIBJcZ111QuO/9FBo41+TAbQV619ezoe3yeUsVaaSNSdDYNr7Pkf+jtPGA+t1OgBJMSgz/KAydi6TNTeCb/vVtFS26TfJ+FBwJovDNXUgWHo0mrQjbyJ+WWCYjNCLTWZWqdEDzLFJ5tOO6by+S3ZBplLo+6r0pCTcv9/VLML3Kl/0g06aKIF65askmIGBVMafkRX/QYuXTKHGHduxzhUNO2ENgU2A3XihWEf3kbygQUWUpBJ9ktcjhdbM5ZdIzRorcsHOOzCm6qex+l1zJQb8V5CK2B3VqCYeiq/uE0R44ZNSxfpbUKkAGcGokY5B5lPVMWVzAuNyuXdGGV3XFwuYQULlPJLN8OKQjF24f8IOcKsLHu+k06blY8SiE2o8tI9r2IDqGY5QjrLaW4OAytwsAmK2cYqTZmxk8IwQ6UyyChEpAItnlJS84Wuya5I8=
+ ssh_known_hosts: download.kiwix.org
before_script:
- - npm install nightwatch http-server
- - ./node_modules/http-server/bin/http-server . &
+ - npm install nightwatch http-server
+ - "./node_modules/http-server/bin/http-server . &"
script:
- - ./node_modules/nightwatch/bin/nightwatch -c nightwatch.js --env firefox
- - pkill node
+ - "./node_modules/nightwatch/bin/nightwatch -c nightwatch.js --env firefox"
+ - pkill node
+deploy:
+ provider: script
+ script: "./scripts/setup_travis_env.sh && DISPLAY=:99.0 ./scripts/create_all_packages.sh $TRAVIS_TAG"
+ on:
+ branch: master
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 31bcea9b..bb990148 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Kiwix",
- "version": "2.0",
+ "version": "2.0-beta",
"description": "Kiwix : offline wikipedia reader",
@@ -26,6 +26,12 @@
},
"default_title": "Kiwix"
},
+
+ "applications": {
+ "gecko": {
+ "id": "kiwix@kiwix.org"
+ }
+ },
"background": {
"scripts": ["webextension/backgroundscript.js"]
diff --git a/package_app.sh b/package_app.sh
deleted file mode 100755
index cd25fc14..00000000
--- a/package_app.sh
+++ /dev/null
@@ -1 +0,0 @@
-zip -r kiwix.zip www manifest.webapp LICENSE-GPLv3.txt service-worker.js README.md
diff --git a/push_to_gh_pages.sh b/push_to_gh_pages.sh
deleted file mode 100755
index 4a43edd4..00000000
--- a/push_to_gh_pages.sh
+++ /dev/null
@@ -1 +0,0 @@
-git checkout gh-pages; git merge master; git push; git checkout master
diff --git a/scripts/create_all_packages.sh b/scripts/create_all_packages.sh
new file mode 100755
index 00000000..5f8ca043
--- /dev/null
+++ b/scripts/create_all_packages.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
+echo "BASEDIR is $BASEDIR"
+cd $BASEDIR
+
+# Set the secret environment variables if available
+# The file set_secret_environment_variables.sh should not be commited for security reasons
+# It is only useful to run the scripts locally.
+# Travis injects the same environment variables by itself
+if [ -r "$BASEDIR/scripts/set_secret_environment_variables.sh" ]; then
+ . "$BASEDIR/scripts/set_secret_environment_variables.sh"
+fi
+
+# Use the first argument as a version number, else use the Travis tag, else use the commit id
+VERSION_TO_REPLACE="2\.0-beta"
+VERSION_PREFIX="2.0.0"
+if [ ! "$1zz" == "zz" ]; then
+ VERSION=$1
+ echo "Packaging version $VERSION because it has been passed as an argument"
+else
+ COMMIT_ID=$(git rev-parse --short HEAD)
+ VERSION="${VERSION_PREFIX}commit-${COMMIT_ID}"
+ echo "Packaging version $VERSION"
+fi
+
+# Copy only the necessary files in a temporary directory
+mkdir -p tmp
+rm -rf tmp/*
+cp -r www webextension manifest.json manifest.webapp LICENSE-GPLv3.txt service-worker.js README.md tmp/
+
+# Replace the version number everywhere
+# But Chrome would only accept a numeric version number : if it's not, we only use the prefix in manifest.json
+regexpNumericVersion='^[0-9\.]+$'
+if [[ $VERSION =~ $regexpNumericVersion ]] ; then
+ sed -i -e "s/$VERSION_TO_REPLACE/$VERSION/" tmp/manifest.json
+else
+ sed -i -e "s/$VERSION_TO_REPLACE/$VERSION_PREFIX/" tmp/manifest.json
+fi
+sed -i -e "s/$VERSION_TO_REPLACE/$VERSION/" tmp/manifest.webapp
+sed -i -e "s/$VERSION_TO_REPLACE/$VERSION/" tmp/www/index.html
+
+mkdir -p build
+rm -rf build/*
+# Package for Chromium/Chrome
+scripts/package_chrome_extension.sh $VERSION
+# Package for Firefox and Firefox OS
+# We have to put the real version string inside the manifest.json (which Chrome might not have accepted)
+# So we take the original manifest again, and replace the version inside it again
+cp manifest.json tmp/
+sed -i -e "s/$VERSION_TO_REPLACE/$VERSION/" tmp/manifest.json
+scripts/package_firefox_extension.sh $VERSION
+scripts/package_firefoxos_app.sh $VERSION
+
+CURRENT_DATE=$(date +'%Y-%m-%d')
+# Upload the files on download.kiwix.org
+echo "Uploading the files on http://download.kiwix.org/nightly/$CURRENT_DATE/"
+scp -r -p -i scripts/travisci_builder_id_key build/* nightlybot@download.kiwix.org:/var/www/download.kiwix.org/nightly/$CURRENT_DATE
\ No newline at end of file
diff --git a/scripts/package_chrome_extension.sh b/scripts/package_chrome_extension.sh
new file mode 100755
index 00000000..15c65c5a
--- /dev/null
+++ b/scripts/package_chrome_extension.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
+cd $BASEDIR
+VERSION=$1
+
+echo "Packaging unsigned Chrome extension, version $VERSION"
+zip -r build/kiwix-chrome-unsigned-extension-$VERSION.zip www webextension manifest.json LICENSE-GPLv3.txt service-worker.js README.md
+# Package the extension with Chromium
+echo "Signing the extension for Chrome with a local Chromium, version $VERSION"
+chromium-browser --no-sandbox --pack-extension=tmp --pack-extension-key=./scripts/kiwix-html5.pem
+mv tmp.crx build/kiwix-chrome-signed-extension-$VERSION.crx
diff --git a/scripts/package_firefox_extension.sh b/scripts/package_firefox_extension.sh
new file mode 100755
index 00000000..1e3fb6f3
--- /dev/null
+++ b/scripts/package_firefox_extension.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
+cd $BASEDIR
+VERSION=$1
+
+# Install web-ext if it's not already installed
+if [ ! -f node_modules/web-ext/bin/web-ext ]; then
+ npm install web-ext
+fi
+
+cd tmp
+echo "Packaging unsigned Firefox extension, version $VERSION"
+zip -r ../build/kiwix-firefox-unsigned-extension-$VERSION.xpi www webextension manifest.json LICENSE-GPLv3.txt service-worker.js README.md
+
+# Sign the extension with the Mozilla API through web-ext
+echo "Signing the extension for Firefox with Mozilla API, version $VERSION"
+../node_modules/web-ext/bin/web-ext sign --api-key=${MOZILLA_API_KEY} --api-secret=${MOZILLA_API_SECRET}
+mv web-ext-artifacts/*.xpi ../build/kiwix-firefox-signed-extension-$VERSION.xpi
diff --git a/scripts/package_firefoxos_app.sh b/scripts/package_firefoxos_app.sh
new file mode 100755
index 00000000..88318be3
--- /dev/null
+++ b/scripts/package_firefoxos_app.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
+cd $BASEDIR/tmp
+VERSION=$1
+echo "Packaging unsigned Firefox OS application, version $VERSION"
+zip -r ../build/kiwix-firefoxos-$VERSION.zip www manifest.webapp LICENSE-GPLv3.txt service-worker.js README.md
diff --git a/scripts/push_to_gh_pages.sh b/scripts/push_to_gh_pages.sh
new file mode 100755
index 00000000..2796b272
--- /dev/null
+++ b/scripts/push_to_gh_pages.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
+cd $BASEDIR/tmp
+git checkout gh-pages; git merge master; git push; git checkout master
\ No newline at end of file
diff --git a/scripts/secret_files.tar.gz.enc b/scripts/secret_files.tar.gz.enc
new file mode 100644
index 00000000..49feeef3
Binary files /dev/null and b/scripts/secret_files.tar.gz.enc differ
diff --git a/scripts/setup_travis_env.sh b/scripts/setup_travis_env.sh
new file mode 100755
index 00000000..3299c33d
--- /dev/null
+++ b/scripts/setup_travis_env.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
+# Decrypt the secret files
+openssl aes-256-cbc -K $encrypted_3275b0f28807_key -iv $encrypted_3275b0f28807_iv -in $BASEDIR/scripts/secret_files.tar.gz.enc -out $BASEDIR/scripts/secret_files.tar.gz -d
+tar xvzf $BASEDIR/scripts/secret_files.tar.gz --directory $BASEDIR/scripts/
+# On Travis, we need to make Chromium believe it has a display else it fails signing the package
+export DISPLAY=:99.0
+sh -e /etc/init.d/xvfb start
diff --git a/www/index.html b/www/index.html
index 21a75ed5..53ebe67d 100644
--- a/www/index.html
+++ b/www/index.html
@@ -51,7 +51,7 @@
- Kiwix 2.0 beta
+ Kiwix 2.0-beta