forked from martymac/fpart
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake_release.sh
executable file
·55 lines (41 loc) · 1.5 KB
/
make_release.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
#!/bin/sh
# Generates a release tarball
_release=$(git tag | tail -n 1)
_target_dir="/tmp"
# Print a message to stderr and exit with error code 1
end_die () {
[ -n "$1" ] && echo "$1" 1>&2
exit 1
}
cd $(dirname "${0}")/ || \
end_die "Cannot change directory"
echo "Checking out tag ${_release}..."
{ git checkout "${_release}" && \
[ "$(git status --porcelain)" = "" ] ;} || \
end_die "Current branch not clean, cannot proceed"
echo "Copying sources to ${_target_dir}/${_release}..."
{ mkdir -p "${_target_dir}/" && \
cp -Rf ./ "${_target_dir}/${_release}" ;} || \
end_die "Error copying sources"
echo "Running autoreconf..."
echo "=="
(cd "${_target_dir}/${_release}" && \
autoreconf -fi && echo "==") || \
end_die "Error running autoreconf"
echo "Generating tarball..."
{ tar c -C "${_target_dir}" -zf "${_target_dir}/${_release}.tar.gz" \
--exclude ".git*" --exclude "autom4te.cache" "${_release}/" ;} || \
end_die "Error generating file: ${_target_dir}/${_release}.tar.gz"
echo "Created file: ${_target_dir}/${_release}.tar.gz"
echo "Signing release..."
gpg --detach-sign --armor ${_target_dir}/${_release}.tar.gz || \
end_die "Could not sign tarball"
echo "Created signature: ${_target_dir}/${_release}.tar.gz.asc"
echo "Cleaning up temporary directory..."
rm -rf "${_target_dir}/${_release}" || \
end_die "Error cleaning up: ${_target_dir}/${_release}"
echo "Coming back to master branch..."
git checkout "master" || \
end_die "Could not checkout master branch"
echo "done."
exit 0