forked from rundeck-plugins/nixy-step-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·54 lines (42 loc) · 961 Bytes
/
build.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
#!/usr/bin/env bash
set -eu
: "${BASEDIR:=.}"
: "${BUILDIR:=$BASEDIR/build}"
mkdir -p "$BUILDIR/dist"
cd "$BASEDIR"
BASENAME=$(basename "$(pwd)")
PLUGINS=( $(for f in */plugin.yaml; do dirname "$f"; done) )
package() {
local -r build_dir=$1 plugin=$2
mkdir -p "$build_dir/$BASENAME-$plugin"
cp -r "$plugin"/* "$build_dir/$BASENAME-$plugin"
(cd "$build_dir" &&
zip -r "dist/${BASENAME}-${plugin}.zip" "$BASENAME-$plugin")
}
install() {
local -r build_dir=$1 plugin=$2
cp -v "$BUILDIR/dist/${BASENAME}-${plugin}.zip" "$RDECK_BASE/libext"
}
package_all() {
local -ra plugins=("$@")
for plugin in ${plugins[*]:-}
do
package $BUILDIR "$plugin"
done
}
install_all() {
local -ra plugins=("$@")
for plugin in ${plugins[*]:-}
do
install $BUILDIR "$plugin"
done
}
# Package the plugins
package_all "${PLUGINS[@]}"
# Copy the plugins to the libext directory
if [[ -n "${RDECK_BASE:-}" ]]
then
install_all "${PLUGINS[@]}"
fi
exit $?
# end.