-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathbundle-templates.sh
42 lines (30 loc) · 1.01 KB
/
bundle-templates.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
#!/bin/bash -eu
# Download element templates as JSON for all bundled connectors to be distributed
# as single ZIP file on the Github Release page
set -o pipefail
RELEASE_VERSION=${1:-SNAPSHOT}
ARTIFACT_DIR=${PWD}
WORKING_DIR="$(mktemp -d)"
trap 'rm -rf -- "${WORKING_DIR}"' EXIT
pushd ${WORKING_DIR}
find ${ARTIFACT_DIR} -name "*.json" | grep "element-templates" |\
while read TEMPLATE_FILE;
do cp $TEMPLATE_FILE ${WORKING_DIR};
done
tag_version() {
local file=$1
local version=$(cat $file | jq '. | if type == "array" then .[0] else . end | .version')
local base_name="${file%%".json"*}"
if [[ "null" != "$version" ]]; then
echo "tag_version: Renaming $file -> $base_name-$version.json"
mv "$file" "$base_name-$version.json"
else
echo "tag_version: Keeping $file (unversioned)"
fi
}
for file in *.json; do
tag_version $file
done
tar czvf ${ARTIFACT_DIR}/connectors-bundle-templates-${RELEASE_VERSION}.tar.gz *.json
zip ${ARTIFACT_DIR}/connectors-bundle-templates-${RELEASE_VERSION}.zip *.json
popd