Skip to content

Commit

Permalink
Add basic release tooling
Browse files Browse the repository at this point in the history
Run ./release.sh <VERSION> to prepare a new release.
  • Loading branch information
t-lo committed May 12, 2023
1 parent f933734 commit 2293c3d
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ settings.env
_server_workspace_
mailman.yaml
start_mailman.sh
mailserver*.tgz
VERSION
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Dockerised mailserver, inspired by https://jan.wildeboer.net/2022/08/Email-1-Pos

For detailed set-up and operations instructions please consult the [wiki](https://github.com/t-lo/mailserver/wiki)

First, clone the [repository](https://github.com/t-lo/) or download a [release tarball](https://github.com/t-lo/mailserver/releases).

**Set up server**

1. `cp settings.env.empty settings.env`; edit `settings.env` and fill in:
Expand Down
12 changes: 12 additions & 0 deletions release-files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
contrib/
grafana/
prometheus/
systemd/
LICENSE
README.md
dns_check.sh
settings.env.empty
start_mailserver.sh
start_monitoring.sh
user.sh
VERSION
70 changes: 70 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/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 baove). Please commit and push or remove bevore creating a release."
exit 1
fi

yell "Building the container image"
docker build -t "${container}:${version}" .
docker tag "${container}:latest" "${container}:${version}"

yell "Creating the release tarball"
echo "${release_name}" >VERSION
tar czvf "${release_name}.tgz" -T release-files.txt

yell "Creating the release tag"
git tag "${release_name}"

yell "Done."

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"
7 changes: 6 additions & 1 deletion start_mailserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ cd "$(dirname "$0")"
http="${1:-80}"
https="${2:-443}"

version=""
if [ -f "VERSION" ] ; then
version=":$(cat VERSION)"
fi

# Create mailserver named network for other container services to connect to.
# This is mostly useful for other container services that use LMTP, e.g. mailman3.
docker network rm mailserver-network >/dev/null 2>&1 || true
Expand All @@ -24,4 +29,4 @@ docker run --rm -i -p $http:80 -p $https:443 \
--cap-add CAP_NET_ADMIN \
--cap-add CAP_NET_RAW \
--name mailserver \
ghcr.io/t-lo/mailserver
"ghcr.io/t-lo/mailserver${version}"

0 comments on commit 2293c3d

Please sign in to comment.