File: make-release.sh

package info (click to toggle)
libcoverart 1.0.0%2Bgit20150706-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 424 kB
  • ctags: 285
  • sloc: cpp: 2,213; ansic: 303; sh: 91; xml: 63; makefile: 32
file content (136 lines) | stat: -rw-r--r-- 2,884 bytes parent folder | download | duplicates (3)
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
#!/bin/bash

DoIt()
{
	SRCREPO="git://github.com/metabrainz/libcoverart.git"
	PUSHURL="git@github.com:metabrainz/libcoverart.git"

	#Enable these 4 lines for local access only
	#rm -rf $SRCDIR/../flactag.git-local
	#SRCREPO="$SRCDIR/../libcoverart.git"
	#git init --bare $SRCREPO
	#PUSHURL="$SRCREPO"

	echo "Entering work directory"
	cd $WORKDIR || return 1

	echo "Cloning repository"
	git clone --quiet $SRCREPO . || return 1

	echo "Setting remote push URL"
	git remote set-url origin --push $PUSHURL || return 1

	echo "Running cmake"
	cmake . >/dev/null || return 1

	echo "Making tarball"
	make dist >/dev/null || return 1

	echo "Checking for tarball $TARBALL"
	[ -f $TARBALL ] || return 1

	echo "Copying tarball to $EXTRACTDIR"
	cp $TARBALL $EXTRACTDIR || return 1

	echo "Entering extract directory"
	cd $EXTRACTDIR || return 1

	echo "Extracting tarball"
	tar xzf $TARBALL || return 1

	echo "Building"
	cd libcoverart-$VERSION || return 1
	cmake . > /dev/null || return 1
	make $MAKEARGS > /dev/null || return 1

	echo "Install test"
	mkdir "$EXTRACTDIR/install-test" | return 1
	make DESTDIR="$EXTRACTDIR/install-test" install > /dev/null || return 1

	echo "Installed binary test"
	ldd "$EXTRACTDIR/install-test/usr/local/lib/libcoverart.so" > /dev/null || return 1

	MD5=`md5sum $WORKDIR/$TARBALL | cut -d' ' -f1`
	SHA224=`sha224sum $WORKDIR/$TARBALL | cut -d' ' -f1`

	MAILTEXT="New release of libcoverart $VERSION is attached:\n\nMD5: $MD5\nSHA224: $SHA224"

	if [ "$TAGANDPUSH" -eq "1" ]
	then
		echo "Tagging work repository"

		cd $WORKDIR
		git tag -s -u $KEYID -m "Tag release $VERSION" -m "MD5 checksum: $MD5" -m "SHA224 checksum: $SHA224" $TAGNAME || return 1

		COMMIT=`git show $TAGNAME | grep commit | cut -d ' ' -f 2`

		echo "Pushing new tag to origin"
		git push origin master --tags || return 1

		MAILTEXT="$MAILTEXT\nCOMMIT: $COMMIT\n"

		if ! echo -e "$MAILTEXT" | mutt -s "libcoverart release" -a $TARBALL -- $KEYID
		then
			(echo -e "$MAILTEXT"; uuencode $TARBALL $TARBALL) | Mail -s "libcoverart release" $KEYID
		fi

		git --no-pager show --raw $TAGNAME

		echo
	fi

	echo -e "$MAILTEXT"
	return 0
}

VALIDARGS=0
TAGANDPUSH=0

if [ "$#" -eq "2" -o "$#" -eq "3" ]
then
	VALIDARGS=1

	#rm -rf /tmp/tmp.*

	if [ "$#" -eq "3" ]
	then
		if [ "x$3" = "x--tag-and-push" ]
		then
			TAGANDPUSH=1
		else
			VALIDARGS="0"
		fi
	fi
fi

if [ "$VALIDARGS" -eq "1" ]
then
	VERSION="$1"
	KEYID="$2"

	SRCDIR=`pwd`
	TARBALL="libcoverart-$VERSION.tar.gz"
	TAGNAME="test-$VERSION"

	#Comment this line out to do test pushes
	TAGNAME="release-$VERSION"

	WORKDIR=`mktemp -d`
	EXTRACTDIR=`mktemp -d`

	echo "Using directories $WORKDIR and $EXTRACTDIR"

	DoIt
	RET=$?

	if [ "$RET" -eq "1" -o "$TAGANDPUSH" -eq "1" ]
	then
		rm -rf $WORKDIR
	else
		echo "Files remain in $WORKDIR"
	fi

	rm -rf $EXTRACTDIR
else
	echo "Usage: $0 version keyid [ --tag-and-push ]"
fi