-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.sh
executable file
·77 lines (61 loc) · 1.93 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# Build a release container, generate a release tarball and tag a release.
#
name="mailserver"
container="ghcr.io/t-lo/${name}"
set -euo pipefail
script_dir="$(dirname "$0")"
function yell() {
echo
echo "############# " "${@}" " ##############"
echo
}
# --
if [ -z "${1:-}" ] ; then
echo "Usage: $0 'release-version'"
exit 1
fi
version="$1"
release_name="${name}-${version}"
# Sanity
if ! git diff --exit-code; then
yell "ERROR: Local changes detected (see diff above). Commit and push before creating a release."
exit 1
fi
if ! git diff --staged --exit-code; then
yell "ERROR: Staged changes detected (see diff above). Commit and push before creating a release."
exit 1
fi
untracked="$(git ls-files --other --exclude-standard --directory 2>&1)"
if [ -n "${untracked}" ] ; then
echo
git ls-files --other --exclude-standard --directory 2>&1
yell "ERROR: untracked files detected (see above). Please commit and push or remove before creating a release."
exit 1
fi
yell "Building the container image"
docker build --pull -t "${container}:${version}" .
docker tag "${container}:${version}" "${container}:latest"
yell "Querying version information"
./package_versions.sh "${container}:${version}" release_package_versions.list | tee PACKAGE_VERSIONS
yell "Creating the release tarball"
echo "${version}" >VERSION
tar czvf "${release_name}.tgz" -T release-files.txt
yell "Creating the release tag"
git tag "${release_name}"
yell "Done."
echo "---------------------------------------"
echo "Now run:"
echo " docker push ${container}:${version}"
echo " docker push ${container}:latest"
echo " git push origin"
echo " git push origin ${release_name}"
echo
echo "Then go to"
echo " https://github.com/t-lo/mailserver/releases/new"
echo "to create a new release, and attach ${release_name}.tgz"
echo
echo "Release version information"
echo "---------------------------"
cat PACKAGE_VERSIONS