This repository has been archived by the owner on Oct 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpush-wildfly.sh
executable file
·100 lines (81 loc) · 2.47 KB
/
push-wildfly.sh
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
VERSION=0.0.1
usage() {
cat <<EOF
USAGE:
$(basename "${BASH_SOURCE[0]}") [FLAGS] <version>
FLAGS:
-l, --latest Use 'latest' for tagging the image
-p, --podman Use podman instead of docker
-h, --help Prints help information
-v, --version Prints version information
--no-color Uses plain text output
ARGS:
<version> WildFly version >=10 as <major>[.<minor>]
EOF
exit
}
cleanup() {
trap - SIGINT SIGTERM ERR EXIT
}
setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
# shellcheck disable=SC2034
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}
msg() {
echo >&2 -e "${1-}"
}
die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}
version() {
msg "${BASH_SOURCE[0]} $VERSION"
exit 0
}
parse_params() {
LATEST=false
DOCKER=docker
while :; do
case "${1-}" in
-l | --latest) LATEST=true ;;
-p | --podman) DOCKER=podman ;;
-h | --help) usage ;;
-v | --version) version ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done
ARGS=("$@")
[[ ${#ARGS[@]} -eq 0 ]] && die "Missing WildFly version"
WF_VERSION=${ARGS[0]}
[[ $WF_VERSION =~ ^([0-9]{2})(\.([0-9]{1}))?$ ]] || die "Illegal WildFly version: '$WF_VERSION'. Please use <major>[.<minor>] with mandatory major >= 10 and optional minor >= 0 and <= 9"
WF_MAJOR_VERSION=${BASH_REMATCH[1]}
[[ "${WF_MAJOR_VERSION}" -lt "10" ]] && die "Illegal major WildFly version: '$WF_MAJOR_VERSION'. Must be >= 10"
WF_MINOR_VERSION=${BASH_REMATCH[3]:-0}
[[ "${WF_MINOR_VERSION}" -lt "0" ]] && die "Illegal minor WildFly version: '$WF_MINOR_VERSION'. Must be >= 0"
[[ "${WF_MINOR_VERSION}" -gt "9" ]] && die "Illegal major WildFly version: '$WF_MINOR_VERSION'. Must be <= 9"
return 0
}
parse_params "$@"
setup_colors
TAG=quay.io/halconsole/wildfly
TAG_DOMAIN=quay.io/halconsole/wildfly-domain
RELEASE=$WF_MAJOR_VERSION.$WF_MINOR_VERSION.0.Final
if [[ "$LATEST" == "true" ]]; then
RELEASE=latest
fi
# Requires a valid configuration in ~/.docker/config.json
${DOCKER} login quay.io
${DOCKER} push "${TAG}:${RELEASE}"
${DOCKER} push "${TAG_DOMAIN}:${RELEASE}"