deploy.sh 2.32 KB
Newer Older
Antoine Regimbeau's avatar
Antoine Regimbeau committed
1 2 3
#!/bin/bash
# Configure git for tar.xz
git config tar.tar.xz.command "xz -c"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
4 5

pack_suffix=""
6
if [ $1 = "develop" ] # check if the branch name is develop or not
Antoine Regimbeau's avatar
Antoine Regimbeau committed
7 8 9 10
then # we are on develop
  jobs_directory=/home/otbpush/test/$(date +%F)
else # we are on a release branch
  jobs_directory=/home/otbpush/test/staging
11
  if [ "$#" -eq 2 ]
Antoine Regimbeau's avatar
Antoine Regimbeau committed
12
    then # there is a rc tag, we need a suffix for packages
Antoine Regimbeau's avatar
Antoine Regimbeau committed
13
    pack_suffix=-$(echo "$2" | grep -o "rc[0-9]*") # this retrieve the rc number
Antoine Regimbeau's avatar
Antoine Regimbeau committed
14 15 16 17 18 19
  fi
fi

echo "jobs_directory=${jobs_directory}"
echo "pack_suffix=${pack_suffix}"

Antoine Regimbeau's avatar
Antoine Regimbeau committed
20
# Create today's directory on serveur otb5-vm2
21
echo "Creating today's directory"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
22
ssh otbpush@otb5-vm2.orfeo-toolbox.org mkdir -p ${jobs_directory}
Antoine Regimbeau's avatar
Antoine Regimbeau committed
23
# Delete latest
24
echo "Deleting latest directory"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38
if [ $1 = "develop" ]
then # On develop
  ssh otbpush@otb5-vm2.orfeo-toolbox.org rm -rf /home/otbpush/test/latest
  # Create symilink
  ssh otbpush@otb5-vm2.orfeo-toolbox.org ln -s ${jobs_directory} /home/otbpush/test/latest
  # Cleaning old directory
  matching_dirs=$(ls -1 | grep -oE '^20[0-9]{2}-[0-9]{2}-[0-9]{2}$' | sort)
  history_length=11
  rm -rf $(echo $matching_dirs | tr ' ' '\n' | head -n -${history_length})
else # On release
  # Remove what is inside staging area
  ssh otbpush@otb5-vm2.orfeo-toolbox.org rm -rf ${jobs_directory}/*
fi

Antoine Regimbeau's avatar
Antoine Regimbeau committed
39
# Push package
Antoine Regimbeau's avatar
Antoine Regimbeau committed
40
echo "Renaming binary packages"
41
for name in $(find . -regex "./OTB-.*\(run\|zip\)"); do
42 43
  len=(${#name})
  mv "$name" "${name:0:$len-4}${pack_suffix}${name:$len-4}"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
44
done
Antoine Regimbeau's avatar
Antoine Regimbeau committed
45

46
echo "Pushing binary packages"
47
scp OTB-*.{run,zip} otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/.
Antoine Regimbeau's avatar
Antoine Regimbeau committed
48
# Push doc
49
echo "Pushing documentation"
50
scp {CookBook-*-html.tar.gz,CookBook-*.pdf,OTB-Doxygen-*.tar.bz2} otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/.
Antoine Regimbeau's avatar
Antoine Regimbeau committed
51 52

# Create zip, tar.gz and tar.xy source
53
echo "Creating source tarball and zip"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
54 55 56
git archive --format=zip -o OTB-sources-$CI_COMMIT_SHORT_SHA.zip HEAD
git archive --format=tgz -o OTB-sources-$CI_COMMIT_SHORT_SHA.tar.gz HEAD
git archive --format=tar.xz -o OTB-sources-$CI_COMMIT_SHORT_SHA.tar.xz HEAD
Antoine Regimbeau's avatar
Antoine Regimbeau committed
57
# Remove old source file
58
echo "Removing old sources"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
59
ssh otbpush@otb5-vm2.orfeo-toolbox.org \
Antoine Regimbeau's avatar
Antoine Regimbeau committed
60 61
rm ${jobs_directory}/OTB-sources-*.zip \
${jobs_directory}/OTB-sources-*.tar.*
Antoine Regimbeau's avatar
Antoine Regimbeau committed
62 63

# Push new source file
64
echo "Pushing new sources"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
65 66
scp OTB-sources-$CI_COMMIT_SHORT_SHA.* \
otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/
Antoine Regimbeau's avatar
Antoine Regimbeau committed
67

68