-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.sh
executable file
·44 lines (40 loc) · 1.24 KB
/
upload.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
echo "Get current version"
dir=circus.robocalc.robosim.update/target/repository/
remote=${ROBOSTAR_WEB_ROOT}/robotool/robosim-metamodel/
url=${ROBOSTAR_WEB_USER}@${ROBOSTAR_WEB_HOST}
file=$(ls $dir/features | grep -m 1 jar)
version=${file#*_}
version=${version%.jar}
BRANCH_NAME=${GITHUB_REF##*/}
# Use the branch name to choose the name of the branch. This assumes
# no branch of name 'update' will ever be used.
if [[ $BRANCH_NAME = master ]];
then
update=update
else
update=$BRANCH_NAME
fi
if [[ $version = *[!\ ]* ]];
then
echo "Current version:" $version;
echo "Branch:" $BRANCH_NAME;
dest=${update}_${version}
echo "Target dir:" $dest;
rm -rf tmp
mkdir tmp && cd tmp
mkdir $dest
cp -r ../$dir/* $dest
# Deploy a copy of the ECore file as well
cp ../circus.robocalc.robosim/model/robosim.ecore $dest
# In the new host, it is not possible to generate a symlink that points to
# a non-existent target, such as 'update', before it is actually created.
# So here we first transfer the update folder, then create the symlink and
# finally transfer that too.
rsync -a -e "ssh" -rtzh . $url:$remote
ln -s $dest ${update}
rsync -a -e "ssh" -rtzh . $url:$remote
exit $?;
else
echo "Couldn't find current version"
exit 1;
fi