deploy.sh 2.41 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 13 14 15 16 17 18 19
    then # there is a rc tag, we need a suffix for packages
    pack_suffix=$(echo "$2" | grep -o "rc[0-9]*") # this retrieve the rc number
  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 41 42 43 44 45
echo "Renaming binary packages"
find build_packages/. -name "*.run" \
-exec sh -c 'mv "$1" "${1%.run}${pack_suffix}.run"' _ {} \;

# TO REMOVE
###########
46
ls -all build_packages/
Antoine Regimbeau's avatar
Antoine Regimbeau committed
47 48
###########

49
echo "Pushing binary packages"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
50
scp build_packages/*.run otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/.
Antoine Regimbeau's avatar
Antoine Regimbeau committed
51
# Push doc
52
echo "Pushing documentation"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
53 54 55
scp build/{CookBook-*-html.tar.gz,\
/Documentation/{Cookbook/latex/CookBook-*.pdf,\
Documentation/Doxygen/OTB-Doxygen-*.tar.bz2}} \
Antoine Regimbeau's avatar
Antoine Regimbeau committed
56
otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/.
Antoine Regimbeau's avatar
Antoine Regimbeau committed
57 58

# Create zip, tar.gz and tar.xy source
59
echo "Creating source tarball and zip"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
60 61 62
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
63
# Remove old source file
64
echo "Removing old sources"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
65
ssh otbpush@otb5-vm2.orfeo-toolbox.org \
Antoine Regimbeau's avatar
Antoine Regimbeau committed
66 67
rm ${jobs_directory}/OTB-sources-*.zip \
${jobs_directory}/OTB-sources-*.tar.*
Antoine Regimbeau's avatar
Antoine Regimbeau committed
68 69

# Push new source file
70
echo "Pushing new sources"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
71 72
scp OTB-sources-$CI_COMMIT_SHORT_SHA.* \
otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/
Antoine Regimbeau's avatar
Antoine Regimbeau committed
73 74