2018-06-30 17:01:23 -06:00
|
|
|
#!/bin/bash
|
2018-08-01 17:50:09 -06:00
|
|
|
BASE="$PWD"
|
2018-06-30 17:01:23 -06:00
|
|
|
SRC="$BASE/src"
|
|
|
|
BUILD="$BASE/build"
|
|
|
|
MANIFEST_IN="$SRC/manifest.json"
|
|
|
|
MANIFEST_OUT="$BUILD/manifest.json"
|
|
|
|
|
2018-07-08 06:05:04 -06:00
|
|
|
VER=$(grep '"version":' "$MANIFEST_IN" | sed -re 's/.*": "(.*?)".*/\1/')
|
2018-07-06 19:02:40 -06:00
|
|
|
if [ "$1" == "tag" ]; then
|
|
|
|
echo "Tagging at $VER"
|
|
|
|
git tag -a "$VER" && git push origin "$VER"
|
|
|
|
exit 0
|
|
|
|
fi
|
2018-10-13 15:07:52 -06:00
|
|
|
if [[ "$1" == "rel" ]]; then
|
2018-10-12 14:34:42 -06:00
|
|
|
perl -pi.bak -e 's/("version":.*)rc\d+/$1/' "$MANIFEST_IN"
|
|
|
|
rm -f "$MANIFEST_IN".bak
|
2018-08-23 18:56:59 -06:00
|
|
|
"$0" && "$0" bump
|
|
|
|
exit
|
|
|
|
fi
|
2018-10-13 15:07:52 -06:00
|
|
|
|
|
|
|
if [[ "$1" == "bump" ]]; then
|
|
|
|
if [[ "$2" ]]; then
|
2018-08-25 16:37:52 -06:00
|
|
|
NEW_VER="$2"
|
|
|
|
if [[ "$2" == *.* ]]; then # full dotted version number
|
|
|
|
pattern='"\d+.*?'
|
|
|
|
NEW_VER='"'"$2"
|
|
|
|
elif [[ "$2" == *rc* ]]; then # new RC after release
|
|
|
|
if [[ "$2" == rc* ]]; then
|
2018-12-27 02:50:04 -07:00
|
|
|
if [[ ! "$VER" == *rc* ]]; then
|
|
|
|
echo >&2 "Please specify next release version (like 12rc1). Current is $VER"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
pattern='rc\d+'
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
pattern='\b(?:\d+rc)?\d+'
|
2018-08-25 16:37:52 -06:00
|
|
|
fi
|
|
|
|
else # incremental version
|
|
|
|
pattern='\b\d+'
|
|
|
|
fi
|
|
|
|
REPLACE_EXPR='s/(?<PREAMBLE>"version":.*)'"$pattern"'"/$+{PREAMBLE}'"$NEW_VER"'"/'
|
2018-10-12 14:34:42 -06:00
|
|
|
perl -pi.bak -e $REPLACE_EXPR "$MANIFEST_IN" && "$0" bump
|
|
|
|
rm -f "$MANIFEST_IN".bak
|
2018-08-25 16:37:52 -06:00
|
|
|
exit
|
|
|
|
fi
|
2018-07-08 06:05:04 -06:00
|
|
|
echo "Bumping to $VER"
|
|
|
|
git add "$MANIFEST_IN"
|
|
|
|
git commit -m "Version bump: $VER."
|
2018-10-05 18:47:31 -06:00
|
|
|
[[ $VER == *rc* ]] || "$0" tag
|
2018-08-23 18:56:59 -06:00
|
|
|
exit
|
2018-07-08 06:05:04 -06:00
|
|
|
fi
|
2018-06-30 17:01:23 -06:00
|
|
|
XPI_DIR="$BASE/xpi"
|
|
|
|
XPI="$XPI_DIR/noscript-$VER"
|
|
|
|
LIB="$SRC/lib"
|
|
|
|
TLD="$BASE/TLD"
|
|
|
|
|
2018-10-05 18:47:31 -06:00
|
|
|
if ! [ $(date -r "$LIB/tld.js" +'%Y%m%d') -ge $(date +'%Y%m%d') -a "$1" != "tld" ] && "$TLD/generate.sh" "$LIB/tld.js"; then
|
2018-08-01 17:50:09 -06:00
|
|
|
cp -u "$TLD/tld.js" "$LIB"
|
2018-06-30 17:01:23 -06:00
|
|
|
fi
|
|
|
|
|
2018-07-03 09:36:36 -06:00
|
|
|
./html5_events/html5_events.pl
|
2018-06-30 17:01:23 -06:00
|
|
|
|
2018-07-03 09:36:36 -06:00
|
|
|
rm -rf "$BUILD" "$XPI"
|
|
|
|
cp -pR "$SRC" "$BUILD"
|
|
|
|
cp -p LICENSE.txt GPL.txt "$BUILD"/
|
2018-06-30 17:01:23 -06:00
|
|
|
|
2018-08-23 18:56:59 -06:00
|
|
|
BUILD_CMD="web-ext"
|
|
|
|
BUILD_OPTS="build"
|
2018-10-05 18:47:31 -06:00
|
|
|
|
2018-06-30 17:01:23 -06:00
|
|
|
if [[ $VER == *rc* ]]; then
|
|
|
|
sed -re 's/^(\s+)"strict_min_version":.*$/\1"update_url": "https:\/\/secure.informaction.com\/update\/?v='$VER'",\n\0/' \
|
|
|
|
"$MANIFEST_IN" > "$MANIFEST_OUT"
|
2018-10-13 15:07:52 -06:00
|
|
|
if [[ "$1" == "sign" ]]; then
|
2018-08-23 18:56:59 -06:00
|
|
|
BUILD_CMD="$BASE/../../we-sign"
|
|
|
|
BUILD_OPTS=""
|
|
|
|
fi
|
2018-06-30 17:01:23 -06:00
|
|
|
else
|
|
|
|
grep -v '"update_url":' "$MANIFEST_IN" > "$MANIFEST_OUT"
|
2018-10-13 15:07:52 -06:00
|
|
|
if [[ "$1" == "sign" ]]; then
|
2018-08-23 18:56:59 -06:00
|
|
|
echo >&2 "WARNING: won't auto-sign a release version, please manually upload to AMO."
|
|
|
|
fi
|
2018-06-30 17:01:23 -06:00
|
|
|
fi
|
|
|
|
if ! grep '"id":' "$MANIFEST_OUT" >/dev/null; then
|
|
|
|
echo >&2 "Cannot build manifest.json"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-08-01 17:50:09 -06:00
|
|
|
for file in "$SRC"/content/*.js; do
|
|
|
|
if grep -P '\/\/\s(REL|DEV)_ONLY' "$file" >/dev/null; then
|
2018-08-02 04:19:34 -06:00
|
|
|
sed -re 's/\s*\/\/\s*(\S.*)\s*\/\/\s*REL_ONLY.*/\1/' -e 's/.*\/\/\s*DEV_ONLY.*//' "$file" > "$BUILD/content/$(basename "$file")"
|
2018-08-01 09:48:45 -06:00
|
|
|
fi
|
|
|
|
done
|
2018-06-30 17:01:23 -06:00
|
|
|
|
|
|
|
echo "Creating $XPI.xpi..."
|
2018-07-03 09:36:36 -06:00
|
|
|
mkdir -p "$XPI_DIR"
|
2018-06-30 17:01:23 -06:00
|
|
|
|
2018-10-13 02:34:18 -06:00
|
|
|
if which cygpath; then
|
|
|
|
WEBEXT_IN="$(cygpath -w "$BUILD")"
|
|
|
|
WEBEXT_OUT="$(cygpath -w "$XPI_DIR")"
|
|
|
|
else
|
|
|
|
WEBEXT_IN="$BUILD"
|
|
|
|
WEBEXT_OUT="$XPI_DIR"
|
|
|
|
fi
|
|
|
|
|
2019-04-01 03:56:39 -06:00
|
|
|
"$BUILD_CMD" $BUILD_OPTS --overwrite-dest --source-dir="$WEBEXT_IN" --artifacts-dir="$WEBEXT_OUT" --ignore-files=test/XSS_test.js
|
2018-06-30 17:01:23 -06:00
|
|
|
SIGNED="$XPI_DIR/noscript_security_suite-$VER-an+fx.xpi"
|
|
|
|
if [ -f "$SIGNED" ]; then
|
|
|
|
mv "$SIGNED" "$XPI.xpi"
|
2018-10-14 17:40:20 -06:00
|
|
|
../../we-publish "$XPI.xpi"
|
2018-06-30 17:01:23 -06:00
|
|
|
elif [ -f "$XPI.zip" ]; then
|
2019-04-01 03:56:39 -06:00
|
|
|
[[ "$VER" == *rc* ]] && xpicmd="mv" || xpicmd="cp"
|
|
|
|
$xpicmd "$XPI.zip" "$XPI.xpi"
|
2018-06-30 17:01:23 -06:00
|
|
|
else
|
|
|
|
echo >&2 "ERROR: Could not create $XPI.xpi!"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
echo "Created $XPI.xpi"
|
|
|
|
rm -rf "$BUILD"
|