forked from pulp/pulp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag.sh
executable file
·176 lines (155 loc) · 2.42 KB
/
tag.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
#
# Tagging script
#
VERSION=
BUILD_TAG=
GIT="git"
TITO="tito"
TITO_TAG_FLAGS=
BRANCH=
GIT_ROOTS="pulp pulp_rpm pulp_puppet"
PACKAGES="
pulp/platform/
pulp/builtins/
pulp_rpm/
pulp_puppet/"
NEXT_VR_SCRIPT=\
$(cat << END
import sys
sys.path.insert(0, 'rel-eng/lib')
import tools
print tools.next()
END
)
set_version()
{
pushd pulp
VERSION=`python -c "$NEXT_VR_SCRIPT"`
exit_on_failed
popd
}
tito_tag()
{
pushd $1
$TITO tag $TITO_TAG_FLAGS && $GIT push origin HEAD && $GIT push --tags
exit_on_failed
popd
}
git_tag()
{
pushd $1
$GIT tag -m "Build Tag" $BUILD_TAG && $GIT push --tags
exit_on_failed
popd
}
git_prep()
{
verify_branch $1
for DIR in $GIT_ROOTS
do
pushd $DIR
echo "Preparing git in repository: $DIR using: $1"
$GIT checkout $1 && $GIT pull --rebase
exit_on_failed
popd
done
}
verify_branch()
{
for DIR in $GIT_ROOTS
do
pushd $DIR
$GIT fetch --tags
$GIT tag -l $1 | grep $1 >& /dev/null
if [ $? = 0 ]; then
echo "[$1] must be a branch."
exit 1
fi
popd
done
}
exit_on_failed()
{
if [ $? != 0 ]; then
exit 1
fi
}
usage()
{
cat << EOF
usage: $0 options
This script tags all pulp projects
OPTIONS:
-h Show this message
-v The pulp version and release. Eg: 2.0.6-1
-a Auto accept the changelog
-b Checkout the specified branch
EOF
}
while getopts "hav:b:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
v)
VERSION=$OPTARG
;;
a)
TITO_TAG_FLAGS="$TITO_TAG_FLAGS --accept-auto-changelog"
;;
b)
BRANCH=$OPTARG
;;
?)
usage
exit
;;
esac
done
# git preparation
if [[ -n $BRANCH ]]
then
echo "Prepare git repositories using: [$BRANCH]"
read -p "Continue [y|n]: " ANS
if [ $ANS = "y" ]
then
git_prep $BRANCH
echo ""
echo ""
fi
fi
# version based on main pulp project
# unless specified using -v
if [[ -z $VERSION ]]
then
set_version
fi
# confirmation
echo ""
echo ""
echo "Using:"
echo " version [$VERSION]"
echo " tito options: $TITO_TAG_FLAGS"
echo ""
read -p "Continue [y|n]: " ANS
if [ $ANS != "y" ]
then
exit 0
fi
# used by tagger
PULP_VERSION_AND_RELEASE=$VERSION
export PULP_VERSION_AND_RELEASE
BUILD_TAG="build-$VERSION"
# tito tagging
for PACKAGE in $PACKAGES
do
tito_tag $PACKAGE
done
# git (correlated build) tagging
for GIT_ROOT in $GIT_ROOTS
do
git_tag $GIT_ROOT
done