Scripts to package the extensions for Firefox and Chrome.

Can be run locally or on Travis
This commit is contained in:
Mossroy 2017-04-06 15:41:39 +02:00
parent 70a08a0f54
commit f1fff391e5
13 changed files with 133 additions and 11 deletions

7
.gitignore vendored
View File

@ -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

View File

@ -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 . &
- "./node_modules/http-server/bin/http-server . &"
script:
- ./node_modules/nightwatch/bin/nightwatch -c nightwatch.js --env firefox
- "./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

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Kiwix",
"version": "2.0",
"version": "2.0-beta",
"description": "Kiwix : offline wikipedia reader",
@ -27,6 +27,12 @@
"default_title": "Kiwix"
},
"applications": {
"gecko": {
"id": "kiwix@kiwix.org"
}
},
"background": {
"scripts": ["webextension/backgroundscript.js"]
},

View File

@ -1 +0,0 @@
zip -r kiwix.zip www manifest.webapp LICENSE-GPLv3.txt service-worker.js README.md

View File

@ -1 +0,0 @@
git checkout gh-pages; git merge master; git push; git checkout master

57
scripts/create_all_packages.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

4
scripts/push_to_gh_pages.sh Executable file
View File

@ -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

Binary file not shown.

8
scripts/setup_travis_env.sh Executable file
View File

@ -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

View File

@ -51,7 +51,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Kiwix 2.0 beta</a>
<a class="navbar-brand">Kiwix 2.0-beta</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->