Add Firefox support

The release.bash script has been updated, and now depends on a helper
script called generateManifest.bash. A "--browser" flag (shorthand "-b")
has been added to the script in order to specify the target browser.

Now the manifest.json file is saved as a template at
templates/manifest.gjson (gjson stands for Generic JSON), which includes
conditional clauses which indicate what parts of the manifest are
applicable to each browser.

generateManifest.bash generates the src/manifest.json file.

Change-Id: Ib051f3d893045c1377007b9b076ffa7a702d9648
diff --git a/release.bash b/release.bash
index 7c1aebe..311d6c6 100644
--- a/release.bash
+++ b/release.bash
@@ -8,7 +8,10 @@
 
   optional arguments:
     -h, --help     show this help message and exit
-    -c, --channel  indicates the channel of the release. Can be "beta" or "stable".
+    -c, --channel  indicates the channel of the release. Can be "beta"
+                   or "stable". Defaults to "stable".
+    -b, --browser  indicates the target browser for the release. Can be
+                   "chromium" or "gecko". Defaults to "chromium".
 
 END
 }
@@ -19,15 +22,17 @@
 }
 
 # Get options
-opts=$(getopt -l "help,channel:" -o "hc:" -n "$progname" -- "$@")
+opts=$(getopt -l "help,channel:,browser:" -o "hc:b:" -n "$progname" -- "$@")
 eval set -- "$opts"
 
 channel=stable
+browser=chromium
 
 while true; do
   case "$1" in
     -h | --help ) usage; exit; ;;
     -c | --channel ) channel="$2"; shift 2 ;;
+    -b | --browser ) browser="$2"; shift 2 ;;
     * ) break ;;
   esac
 done
@@ -38,8 +43,20 @@
   exit
 fi
 
+if [[ $browser != "chromium" && $browser != "gecko" ]]; then
+  echo "browser parameter value is incorrect."
+  usage
+  exit
+fi
+
 echo "Started building release..."
 
+# First of all, generate the appropriate manifest.json file for the
+# target browser
+dependencies=( ${browser^^} )
+
+bash generateManifest.bash "${dependencies[@]}"
+
 # This is the version name which git gives us
 version=$(git describe --always --tags --dirty)
 
@@ -59,18 +76,19 @@
 if [[ $channel == "beta" ]]; then
   # Change manifest.json to label the release as beta
   set_manifest_field "name" "__MSG_appNameBeta__"
+
+  if [[ $browser == "gecko" ]]; then
+    # Change the extension ID
+    set_manifest_field "id" "twpowertools+beta@avm99963.com"
+  fi
 fi
 
 # Create ZIP file for upload to the Chrome Web Store
 mkdir -p out
-rm -rf out/twpowertools-$version-$channel.zip
-zip -rq out/twpowertools-$version-$channel.zip src -x *.git*
+rm -rf out/twpowertools-$version-$browser-$channel.zip
+zip -rq out/twpowertools-$version-$browser-$channel.zip src -x *.git*
 
-# Revert manifest.json changes
-set_manifest_field "version" "0"
-set_manifest_field "version_name" "dirty"
-if [[ $channel == "beta" ]]; then
-  set_manifest_field "name" "__MSG_appName__"
-fi
+# Clean generated manifest.json file
+rm -f src/manifest.json
 
 echo "Done!"