summaryrefslogtreecommitdiffstats
path: root/releasetag.sh
blob: 21fdad4f31a9d4adf004ff8a440a122824a103e6 (plain)
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
#!/bin/sh
#
# Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# Variables
SCRIPT=$0
REPLICANT_DIR=$1
MANIFEST=$2

ARGS_COUNT=1
COLOR=1
TMP="/tmp"
REPO="../tools/repo"
RELEASE_KEY="4A80EB23"
REMOTE="replicant"
PUSH_REMOTE="git.replicant.us"

VERSION="4.2"
RELEASE="0004"

if [ "$COLOR" = "1" ]
then
	color_start="\033[36m"
	color_end="\033[0m"
else
	color_start=""
	color_end=""
fi

manifest () {
	dir=$( pwd )
	cd "$REPLICANT_DIR"

	$REPO manifest -r > $MANIFEST

	cd "$dir"
}

tag_repos () {
	list=""

	default=$( cat $MANIFEST | grep default | grep "remote=\"$REMOTE\"" )
	if [ "$default" != "" ]
	then
		list=$( cat $MANIFEST | grep project | grep -v "remote=\"" )"\n"
	fi

	list="$list"$( cat $MANIFEST | grep project | grep "remote=\"$REMOTE\"" )

	echo "$list" | while read repo
	do
		path=$( echo "$repo" | sed "s/.*path=\"\([^\"]*\)\".*/\1/g" )
		revision=$( echo "$repo" | sed "s/.*revision=\"\([^\"]*\)\".*/\1/g" )

		dir=$( pwd )
		cd "$REPLICANT_DIR/$path"

		echo "Tagging ""$color_start""$path""$color_end"" with $revision"

		git tag -s -u $RELEASE_KEY -m "Replicant $VERSION $RELEASE images release" -a "replicant-$VERSION-$RELEASE" $revision

		echo "Pusing ""$color_start""$path""$color_end"

		path=$( echo $path | tr '[:upper:]' '[:lower:]' )

		git push "git@$PUSH_REMOTE:replicant/$path.git" "replicant-$VERSION-$RELEASE"

		cd "$dir"
	done
}

print_help () {
	echo "$SCRIPT: [REPLICANT_DIR] (MANIFEST)"
}

# Check for the correct number of args
if [ "$#"  -lt "$ARGS_COUNT" ]
then
	print_help
	exit 1
fi

if [ "$MANIFEST" = "" ]
then
	MANIFEST="$TMP/manifest.xml"
	manifest
fi

tag_repos