mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-24 21:45:46 -04:00
Enhance packaging scripts to handle public releases on tags.
So that Travis automatically runs on tags, and generates the necessary files to be uploaded to Mozilla and Google. Fixes #243
This commit is contained in:
parent
a3d3c76659
commit
8421edb898
@ -15,6 +15,11 @@ script:
|
||||
- pkill node
|
||||
deploy:
|
||||
provider: script
|
||||
script: "./scripts/setup_travis_env.sh && DISPLAY=:99.0 ./scripts/create_all_packages.sh $TRAVIS_TAG"
|
||||
script: "./scripts/setup_travis_env.sh && DISPLAY=:99.0 ./scripts/create_all_packages.sh"
|
||||
on:
|
||||
condition: ( "$TRAVIS_EVENT_TYPE" = "cron" )
|
||||
deploy:
|
||||
provider: script
|
||||
script: "./scripts/setup_travis_env.sh && DISPLAY=:99.0 ./scripts/create_all_packages.sh -t -v $TRAVIS_TAG"
|
||||
on:
|
||||
tags: true
|
||||
|
@ -3,6 +3,18 @@ BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
|
||||
echo "BASEDIR is $BASEDIR"
|
||||
cd $BASEDIR
|
||||
|
||||
# Reading arguments
|
||||
while getopts tdv: option; do
|
||||
case "${option}" in
|
||||
t) TAG="-t";; # Indicates that we're releasing a public version from a tag
|
||||
d) DRYRUN="-d";; # Indicates a dryrun test, that does not modify anything on the network
|
||||
v) VERSION=${OPTARG};; # Gives the version string to use (else it will use the commit id)
|
||||
esac
|
||||
done
|
||||
|
||||
MAJOR_NUMERIC_VERSION="2.0"
|
||||
VERSION_TO_REPLACE="2\.0-WIP"
|
||||
|
||||
# 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.
|
||||
@ -11,15 +23,15 @@ 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-WIP"
|
||||
VERSION_PREFIX="2.0"
|
||||
if [ ! "$1zz" == "zz" ]; then
|
||||
VERSION=$1
|
||||
# Use the passed version number, else use the commit id
|
||||
if [ ! "${VERSION}zz" == "zz" ]; then
|
||||
echo "Packaging version $VERSION because it has been passed as an argument"
|
||||
if [ ! "${TAG}zz" == "zz" ]; then
|
||||
echo "This version is a tag : we're releasing a public version"
|
||||
fi
|
||||
else
|
||||
COMMIT_ID=$(git rev-parse --short HEAD)
|
||||
VERSION="${VERSION_PREFIX}commit-${COMMIT_ID}"
|
||||
VERSION="${MAJOR_NUMERIC_VERSION}commit-${COMMIT_ID}"
|
||||
echo "Packaging version $VERSION"
|
||||
fi
|
||||
|
||||
@ -34,7 +46,7 @@ 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
|
||||
sed -i -e "s/$VERSION_TO_REPLACE/$MAJOR_NUMERIC_VERSION/" 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
|
||||
@ -42,16 +54,20 @@ 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
|
||||
scripts/package_chrome_extension.sh $DRYRUN $TAG -v $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
|
||||
scripts/package_firefox_extension.sh $DRYRUN $TAG -v $VERSION
|
||||
scripts/package_firefoxos_app.sh $DRYRUN $TAG -v $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
|
||||
if [ "${DRYRUN}zz" == "zz" ]; then
|
||||
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
|
||||
else
|
||||
echo "Skipping uploading the files, because it's a dryrun test"
|
||||
fi
|
@ -1,11 +1,23 @@
|
||||
#!/bin/bash
|
||||
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
|
||||
cd $BASEDIR
|
||||
VERSION=$1
|
||||
|
||||
# Reading arguments
|
||||
while getopts tdv: option; do
|
||||
case "${option}" in
|
||||
t) TAG="-t";; # Indicates that we're releasing a public version from a tag
|
||||
d) DRYRUN="-d";; # Indicates a dryrun test, that does not modify anything on the network
|
||||
v) VERSION=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
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
|
||||
if [ "${TAG}zz" == "zz" ]; then
|
||||
# Package the extension with Chromium, if we're not packaging a public version
|
||||
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
|
||||
else
|
||||
echo "This unsigned extension must be manually uploaded to Google to be signed and distributed from their store"
|
||||
fi
|
||||
|
@ -1,39 +1,61 @@
|
||||
#!/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
|
||||
# Reading arguments
|
||||
while getopts tdv: option; do
|
||||
case "${option}" in
|
||||
t) TAG="-t";; # Indicates that we're releasing a public version from a tag
|
||||
d) DRYRUN="-d";; # Indicates a dryrun test, that does not modify anything on the network
|
||||
v) VERSION=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
# Install web-ext if it's not already installed (and if we're not doing a dryrun test)
|
||||
if [ ! -f node_modules/web-ext/bin/web-ext ] && [ "${DRYRUN}zz" == "zz" ]; 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
|
||||
if [ "${TAG}zz" == "zz" ]; then
|
||||
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}
|
||||
if [ "${DRYRUN}zz" == "zz" ]; then
|
||||
# Sign the extension with the Mozilla API through web-ext, if we're not packaging a public version
|
||||
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}
|
||||
else
|
||||
echo "Skipping signing the extension with the Mozilla API, because it's a dryrun test"
|
||||
fi
|
||||
|
||||
# Check if the extension has been signed by Mozilla.
|
||||
# The reason signing usually fails is because the same version has already been signed by Mozilla.
|
||||
# So we try to find the signed extension of the same commit id in a previous nightly build
|
||||
FILECOUNT=$(find web-ext-artifacts -name '*.xpi' | wc -l)
|
||||
if [ $FILECOUNT -ge 1 ]; then
|
||||
echo "Extension properly signed by Mozilla"
|
||||
mv web-ext-artifacts/*.xpi ../build/kiwix-firefox-signed-extension-$VERSION.xpi
|
||||
# Check if the extension has been signed by Mozilla.
|
||||
# The reason signing usually fails is because the same version has already been signed by Mozilla.
|
||||
# So we try to find the signed extension of the same commit id in a previous nightly build
|
||||
FILECOUNT=$(find web-ext-artifacts -name '*.xpi' | wc -l)
|
||||
if [ $FILECOUNT -ge 1 ]; then
|
||||
echo "Extension properly signed by Mozilla"
|
||||
mv web-ext-artifacts/*.xpi ../build/kiwix-firefox-signed-extension-$VERSION.xpi
|
||||
else
|
||||
echo "Extension not signed by Mozilla. It might be because this commit id has already been signed : let's look for it in a previous nightly build"
|
||||
FOUND=0
|
||||
for FILE in $(ssh -i ../scripts/travisci_builder_id_key nightlybot@download.kiwix.org "find /var/www/download.kiwix.org/nightly -name \"kiwix-firefox-signed-extension-$VERSION.xpi\""); do
|
||||
echo "Signed extension found on the server in $FILE : copying it locally"
|
||||
scp -i ../scripts/travisci_builder_id_key nightlybot@download.kiwix.org:$FILE ../build/
|
||||
FOUND=1
|
||||
# We only need the first matching file
|
||||
break
|
||||
done
|
||||
if [ $FOUND -ne 1 ]; then
|
||||
echo "Signed extension not found in a previous build"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Extension not signed by Mozilla. It might be because this commit id has already been signed : let's look for it in a previous nightly build"
|
||||
FOUND=0
|
||||
for FILE in $(ssh -i ../scripts/travisci_builder_id_key nightlybot@download.kiwix.org "find /var/www/download.kiwix.org/nightly -name \"kiwix-firefox-signed-extension-$VERSION.xpi\""); do
|
||||
echo "Signed extension found on the server in $FILE : copying it locally"
|
||||
scp -i ../scripts/travisci_builder_id_key nightlybot@download.kiwix.org:$FILE ../build/
|
||||
FOUND=1
|
||||
# We only need the first matching file
|
||||
break
|
||||
done
|
||||
if [ $FOUND -ne 1 ]; then
|
||||
echo "Signed extension not found in a previous build"
|
||||
fi
|
||||
# When packaging a public version, we need to prepare a 'listed' extension package to submit to Mozilla
|
||||
echo "Replacing the Firefox 'unlisted' extension id by the 'listed' one to be accepted by Mozilla"
|
||||
sed -i -e "s/kiwix-html5-unlisted@kiwix.org/kiwix-html5-listed@kiwix.org/" manifest.json
|
||||
|
||||
echo "Packaging unsigned 'listed' Firefox extension, version $VERSION"
|
||||
zip -r ../build/kiwix-firefox-unsigned-listed-extension-$VERSION.xpi www webextension manifest.json LICENSE-GPLv3.txt service-worker.js README.md
|
||||
echo "This unsigned extension must be manually uploaded to Mozilla to be signed and distributed from their store"
|
||||
fi
|
||||
|
@ -1,6 +1,17 @@
|
||||
#!/bin/bash
|
||||
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
|
||||
cd $BASEDIR/tmp
|
||||
VERSION=$1
|
||||
|
||||
# Reading arguments
|
||||
while getopts tdv: option; do
|
||||
case "${option}" in
|
||||
t) TAG="-t";; # Indicates that we're releasing a public version from a tag
|
||||
d) DRYRUN="-d";; # Indicates a dryrun test, that does not modify anything on the network
|
||||
v) VERSION=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
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
|
||||
|
||||
# NB : The Firefox Marketplace (that distributes signed Firefox OS applications) does not allow new submissions any more
|
||||
|
@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
# This script must be run manually on each release, with the version as first parameter
|
||||
# It must be run after the create_all_packages.sh, so that the tmp directory has been populated
|
||||
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
|
||||
echo "BASEDIR is $BASEDIR"
|
||||
cd $BASEDIR
|
||||
VERSION=$1
|
||||
|
||||
echo "Replacing the Firefox 'unlisted' extension id by the 'listed' one to be accepted by Mozilla"
|
||||
sed -i -e "s/kiwix-html5-unlisted@kiwix.org/kiwix-html5-listed@kiwix.org/" tmp/manifest.json
|
||||
|
||||
cd tmp
|
||||
echo "Packaging unsigned 'listed' Firefox extension, version $VERSION"
|
||||
zip -r ../build/kiwix-firefox-unsigned-listed-extension-$VERSION.xpi www webextension manifest.json LICENSE-GPLv3.txt service-worker.js README.md
|
||||
cd ..
|
||||
|
||||
CURRENT_DATE=$(date +'%Y-%m-%d')
|
||||
# Upload the files on download.kiwix.org
|
||||
echo "Uploading the file 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
|
Loading…
x
Reference in New Issue
Block a user