-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.sh
executable file
·35 lines (26 loc) · 929 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
#!/usr/bin/env bash
#
# Add versions to frontpage
#
JS_FILE="./static/current-version.js"
function next() {
printf "\n" >> "$JS_FILE"
NEXTVERSIONCANDIDATE=$(curl --silent "https://api.github.com/repos/eclipsesource/jsonforms/tags" | grep '"name":' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
if [[ ${NEXTVERSIONCANDIDATE:0:1} == "v" ]] && [[ $NEXTVERSIONCANDIDATE != $CURRENTVERSION ]]; then
NEXTVERSION="${NEXTVERSIONCANDIDATE:1}"
fi
printf "export const nextVersion = '$NEXTVERSION';" >> "$JS_FILE"
}
function current() {
CURRENTVERSION=$(curl --silent "https://api.github.com/repos/eclipsesource/jsonforms/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
printf "export const currentVersion = '$CURRENTVERSION';" >> "$JS_FILE"
}
WITH_NEXT=$1
rm -f "$JS_FILE"
if [[ $WITH_NEXT = "next" ]]; then
current
next
else
current
fi
printf "\n" >> "$JS_FILE"