-
Notifications
You must be signed in to change notification settings - Fork 43
/
deploy
executable file
·67 lines (55 loc) · 1.49 KB
/
deploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -Eu
set -o pipefail
readonly RELEASE_DEFAULT=false
# Set an error handler to log the location of an error before exiting
function _exit_err {
local retval=$1
echo "ERROR: $BASH_SOURCE: line $BASH_LINENO: $BASH_COMMAND" >&2
exit "$retval"
}; trap '_exit_err $?' ERR
# Logs an error, then terminates with nonzero exit code
function die { error "$@"; exit 1; }
# Logs message to stderr
function error {
if (( $# == 1 )); then set -- "%b\n" "$1"; fi
# shellcheck disable=SC2059
printf "$1\n" "${@:2}" >&2
}
# Process options, filter out positional arguments
declare -a positional_args
while (( $# )); do
case $1 in
--release) release_opt=true;;
--) shift; break ;;
-?*) die "ERROR: Unrecognized option $1" ;;
*) positional_args+=("$1") ;;
esac
shift
done
# Handle the positional arguments
if (( ${#positional_args[@]} > 0 )); then
set -- "${positional_args[@]}" "$@"
fi
unset positional_args
function main {
local release=${release_opt-${RELEASE_DEFAULT}}
local package=$1
if ! [[ -r $package ]]; then
die "Could not find package file '%s' for upload" "$package"
fi
local args=()
args+=( upload )
args+=( --client-id "${OAUTH_CLIENT_ID}" )
args+=( --client-secret "${OAUTH_CLIENT_SECRET}" )
args+=( --refresh-token "${OAUTH_REFRESH_TOKEN}" )
args+=( --source "${package}" )
if ${release}; then
args+=( --extension-id "${WEBSTORE_ID_PRODUCTION}" )
else
args+=( --extension-id "${WEBSTORE_ID_DEV}" )
args+=( --auto-publish )
fi
webstore "${args[@]}"
}
main "$@"