avm99963 | 03d5409 | 2020-01-18 21:33:16 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Prints help text |
| 4 | function usage() { |
| 5 | cat << END |
| 6 | |
| 7 | Usage: $progname [--channel CHANNEL] |
| 8 | |
| 9 | optional arguments: |
| 10 | -h, --help show this help message and exit |
| 11 | -c, --channel indicates the channel of the release. Can be "beta" or "stable". |
| 12 | |
| 13 | END |
| 14 | } |
| 15 | |
| 16 | # Get options |
| 17 | opts=$(getopt -l "help,channel:" -o "hc:" -n "$progname" -- "$@") |
| 18 | eval set -- "$opts" |
| 19 | |
| 20 | channel=stable |
| 21 | |
| 22 | while true; do |
| 23 | case "$1" in |
| 24 | -h | --help ) usage; exit; ;; |
| 25 | -c | --channel ) channel="$2"; shift 2 ;; |
| 26 | * ) break ;; |
| 27 | esac |
| 28 | done |
| 29 | |
| 30 | if [[ $channel != "stable" && $channel != "beta" ]]; then |
| 31 | echo "channel parameter value is incorrect." |
| 32 | usage |
| 33 | exit |
| 34 | fi |
| 35 | |
| 36 | echo "Started building release..." |
| 37 | |
| 38 | if [[ $channel == "beta" ]]; then |
| 39 | # Change manifest.json to label the release as beta |
| 40 | sed -i 's/"name": "[^"]*"/"name": "__MSG_appNameBeta__"/' src/manifest.json |
| 41 | sed -i -r 's/"version": "([^"]*)",/"version": "\1",\n "version_name": "\1-beta",/' src/manifest.json |
| 42 | fi |
| 43 | |
| 44 | # Create ZIP file for upload to the Chrome Web Store |
| 45 | mkdir -p out |
| 46 | rm -rf out/infinitegforums-$channel.zip |
| 47 | zip -rq out/infinitegforums-$channel.zip src -x *.git* |
| 48 | |
| 49 | if [[ $channel == "beta" ]]; then |
| 50 | # Revert manifest.json changes |
| 51 | sed -i 's/"name": "[^"]*"/"name": "__MSG_appName__"/' src/manifest.json |
| 52 | sed -i '/"version_name"/d' src/manifest.json |
| 53 | fi |
| 54 | |
| 55 | echo "Done!" |