-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck-last-tag
executable file
·49 lines (37 loc) · 1.12 KB
/
check-last-tag
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
#!/bin/bash
set -e
set -x
TAG_FILE=~/.rtpe.all.tags.new
REPO_ROOT=~/htdocs/dfx.at/rtpengine
LATEST_LN="$REPO_ROOT"/latest
test -f "$TAG_FILE" || exit 0
declare -A BUILD=( ["8.5"]="true" ["9.5"]="true" ["10.5"]="true" ["11.5"]="true" ["12.5"]="true" )
readarray -t LAST_X_BRANCHES < <(cat "$TAG_FILE" | perl -pe 's/^mr(\d+)\.(\d+)\..*/$1.$2/' | sort -nu | tail -n 3)
for BRANCH in "${LAST_X_BRANCHES[@]}"; do
if ! test -d "$REPO_ROOT"/"$BRANCH"; then
echo Repo root "$REPO_ROOT"/"$BRANCH" does not exist
continue
fi
BUILD["$BRANCH"]=true
LAST_BRANCH=$BRANCH
done
for BRANCH in "${!BUILD[@]}"; do
CUR_FILE=~/.rtpe.branch."$BRANCH".last.tag.cur
NEW_TAG=$(grep ^mr"$BRANCH"\\. "$TAG_FILE" | tail -n 1)
if ! test -f "$CUR_FILE"; then
true
else
CUR_TAG=$(<"$CUR_FILE")
test -n "$NEW_TAG"
test "$NEW_TAG" = "$CUR_TAG" && continue
fi
set +e
~/bin/log-wrapper "$RTPENGINE_DEBIAN_SRCDIR"/"$BRANCH"/build-all "$NEW_TAG"
set -e
echo "$NEW_TAG" > "$CUR_FILE"
done
LATEST_LINK=$(readlink "$LATEST_LN" || true)
if ! test "$LATEST_LINK" = "$LAST_BRANCH"; then
rm "$LATEST_LN" || true
ln -s "$LAST_BRANCH" "$LATEST_LN"
fi