create-tags.sh 2.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

set -e

# I (Joseph Mirabel) do not think there
# is a need to create tags for these ones.
# hpp-template-corba
# hpp-environments

# Version
if [ ! $# -eq 1 ]; then
  echo "usage: $0 version"
  exit 1
fi
version=$1

# Packages to tag
# pinocchio
19
20
pkg_main="hpp-util hpp-statistics hpp-fcl hpp-pinocchio \
hpp-constraints hpp-corbaserver hpp-core hpp_tutorial hpp-doc \
21
22
hpp-manipulation hpp-manipulation-corba hpp-manipulation-urdf \
hpp-gepetto-viewer hpp-gui hpp-plot"
Guilhem Saurel's avatar
Guilhem Saurel committed
23
branch="stable"
24
remote="origin"
25

26
c_what="\e[33m"
Joseph Mirabel's avatar
Joseph Mirabel committed
27
28
29
30
c_good="\e[32m"
c_bad="\e[31m"
c_reset="\e[0m"

31
echo "Devel directory is $DEVEL_HPP_DIR"
32
echo -e "${c_what}Checking that everything is good.${c_reset}"
33
# Check that
34
35
# - remote ${remote} is something like https://github.com/humanoid-path-planner/...
# - there is no difference between ${remote}/${branch}
Joseph Mirabel's avatar
Joseph Mirabel committed
36
37
#   and the current working directory.
# - working directory is clean
38
39
for pkg in ${pkg_main}; do
  GIT="git -C ${DEVEL_HPP_DIR}/src/${pkg}"
Joseph Mirabel's avatar
Joseph Mirabel committed
40

41
  remote_origin=$(${GIT} remote get-url ${remote})
Joseph Mirabel's avatar
Joseph Mirabel committed
42
  if [[ ! "$remote_origin" =~ ^.*github.com[:/]humanoid-path-planner/${pkg}.*$ ]]; then
43
    echo -e "${pkg}: ${c_bad}Remote '${remote}' is not the main repo. Should be https://github.com/humanoid-path-planner/${pkg}${c_reset}"
Joseph Mirabel's avatar
Joseph Mirabel committed
44
    # exit 1
45
  fi
Joseph Mirabel's avatar
Joseph Mirabel committed
46
47

  #current_branch=$(${GIT} rev-parse --abbrev-ref HEAD)
48
49
  #if [ ! "${current_branch}" == "${branch}" ]; then
  #  echo "${pkg}: Current branch is ${current_branch}. Should be ${branch}."
Joseph Mirabel's avatar
Joseph Mirabel committed
50
51
  #  exit 1
  #fi
52
  ${GIT} update-index -q --refresh
53
  CHANGED=$(${GIT} diff-index --name-only ${remote}/${branch} --)
Joseph Mirabel's avatar
Joseph Mirabel committed
54
  if [ -n "${CHANGED}" ]; then
55
    echo -e "${pkg}: ${c_bad}Not synchronized with ${remote}/${branch}${c_reset}."
Joseph Mirabel's avatar
Joseph Mirabel committed
56
57
58
    exit 1
  fi

59
60
  CHANGED=$(${GIT} diff-index --name-only HEAD --)
  if [ -n "${CHANGED}" ]; then
Joseph Mirabel's avatar
Joseph Mirabel committed
61
62
    echo -e "${pkg}: ${c_bad}Working directory not clean${c_reset}."
    exit 1
63
  fi
Joseph Mirabel's avatar
Joseph Mirabel committed
64
  echo -e "${pkg}: ${c_good}Ok${c_reset}."
65
66
67
done

# Create the tags
68
echo -e "${c_what}Create tags ${version}.${c_reset}"
69
70
for pkg in ${pkg_main}; do
  GIT="git -C ${DEVEL_HPP_DIR}/src/${pkg}"
71
  ${GIT} tag -a -m "Release of version ${version}" ${version}
Joseph Mirabel's avatar
Joseph Mirabel committed
72
  echo -e "${pkg}: ${c_good}Ok${c_reset}."
73
done
Joseph Mirabel's avatar
Joseph Mirabel committed
74
75
76
77

# Push the tags
read -p "Push the tags ? [y/N]" answer
if [[ "${answer}" =~ ^[yY]$ ]]; then
78
  echo -e "${c_what}Push tags ${version} to ${remote}.${c_reset}"
Joseph Mirabel's avatar
Joseph Mirabel committed
79
80
  for pkg in ${pkg_main}; do
    GIT="git -C ${DEVEL_HPP_DIR}/src/${pkg}"
81
    ${GIT} push --quiet ${remote} ${version}
Joseph Mirabel's avatar
Joseph Mirabel committed
82
83
84
    echo -e "${pkg}: ${c_good}Ok${c_reset}."
  done
fi