forked from deephaven/deephaven-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_version.sh
More file actions
executable file
·148 lines (131 loc) · 4.9 KB
/
update_version.sh
File metadata and controls
executable file
·148 lines (131 loc) · 4.9 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# This script is used to update the version of a given plugin in its source code.
# Because this differs for various plugins, this script is used to hide all that complexity
# behind a very simple API. `update_version.sh <plugin-name> <new-version>`
# You should not need to call this script directly.
# It is invoked for you when calling the release.sh script located next to this one.
tab=$'\t'
log_prefix="$(id -un)$tab - "
set -o errexit
set -o nounset
set -o pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")
function log_error() {
{ echo -e "\033[31m$log_prefix $(date "+%Y-%m-%d %H:%M:%S")$tab |--- [ERROR] $* \033[0m" ; } 2> /dev/null
} 2>/dev/null
function log_info() {
{ echo "$log_prefix $(date "+%Y-%m-%d %H:%M:%S")$tab |--- $*" ; } 2>/dev/null
} 2>/dev/null
all_plugins="$(cd "$ROOT_DIR/plugins" ; find . -mindepth 1 -maxdepth 1 -type d | sed 's|./||g')"
function usage() {
log_info "Simple utility to update plugin file in order to change versions."
log_info "This script accepts the following arguments:"
log_info ""
log_info "--help | -h $tab-> Prints this help message"
log_info "--debug | -d $tab-> Turn on xtrace debugging"
log_info "--dev $tab-> Append .dev0 to python plugin versions"
log_info "<plugin name> $tab-> The name of the plugin that we are going to set the version for"
log_info "Valid <plugin name> choices are:
$all_plugins"
log_info "<plugin version> $tab-> Specify the new version of the given plugin"
} 2> /dev/null
package=
version=
dev=false
while (( $# > 0 )); do
case "$1" in
--debug | -d)
set -o xtrace ;;
--dev)
dev=true ;;
--help | -h)
usage ; exit 0 ;;
*)
if [ -z "$package" ]; then
if grep -qE "^$1\$" <<< "$all_plugins"; then
package="$1"
else
{
log_error "Illegal argument $1. Expected one of:
$all_plugins"
} 2>/dev/null
exit 93
fi
elif [ -z "$version" ]; then
version="${1/v/}"
else
{
log_error "Illegal argument $1. Already saw package '$package' and version '$version'"
log_error "This script expects two and only two non -flag arguments, <package name> and <package version>"
} 2>/dev/null
exit 94
fi
;;
esac
shift
done
if [ -z "$package" ]; then
{
log_error "Expected exactly two arguments <package name> <package version>"
log_error "Valid choices for <package name> are:
$all_plugins"
} 2>/dev/null
exit 92
fi
if [ -z "$version" ]; then
{
log_error "Did not receive a second argument of a version to set $package to"
} 2>/dev/null
exit 91
fi
function update_file() {
local file="$1"
local prefix="$2"
local suffix="$3"
local extra="${4:-}"
local expected="${prefix}${version}${extra}${suffix}"
if ! grep -q "$expected" "$ROOT_DIR/plugins/$file"; then
# annoyingly, sed on mac is extremely old, so we have to handle it differently.
if [[ "$(uname)" == Darwin* ]]; then
sed -e "s/${prefix}.*/${expected}/g" -i '' "$ROOT_DIR/plugins/$file"
else
sed -e "s/${prefix}.*/${expected}/g" -i "$ROOT_DIR/plugins/$file"
fi
fi
}
extra=
[ "$dev" = true ] && extra=".dev0"
case "$package" in
ag-grid | json | matplotlib | pivot | plotly | plotly-express | ui | utilities | packaging)
update_file "${package}/setup.cfg" 'version = ' '' "$extra"
;;
auth-keycloak | dashboard-object-viewer | table-example)
# Packages that don't have any Python to publish, just ignore
;;
*)
{
log_error "Unhandled plugin $package. You will need to add wiring in $SCRIPT_NAME"
exit 90
}
esac
# We still need to bump these JS packages for Enterprise legacy reasons, even though they're packaged with Python
npm_version="${version}"
if [ "$dev" != true ]; then
case "$package" in
ag-grid | auth-keycloak | dashboard-object-viewer | matplotlib | pivot | plotly | plotly-express | table-example | ui)
# The working directory is already `plugins/<package-name>`, so we just specify workspace as `src/js` and it does the right thing
npm version "$npm_version" --workspace=src/js
;;
json | packaging | utilities)
# Packages that don't have any JS to publish, just ignore
;;
*)
{
log_error "Unhandled JS plugin $package. You will need to add JS wiring in $SCRIPT_NAME"
exit 90
}
esac
fi
log_info "Done updating $package version to $version${extra}"