deploy.sh 2.52 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"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
41 42 43 44 45 46
# find build_packages/. -name "*.run" \
# -exec sh -c 'mv "$1" "${1%.run}${pack_suffix}.run"' _ {} \;
for name in $(find build_packages/. -name "*.run")
  do 
  mv "$name" "${name%.run}${pack_suffix}.run"
done
Antoine Regimbeau's avatar
Antoine Regimbeau committed
47 48
# TO REMOVE
###########
49
ls -all build_packages/
Antoine Regimbeau's avatar
Antoine Regimbeau committed
50 51
###########

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

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

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