diff --git a/.gitignore b/.gitignore index 1577566..5bcc25e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ settings.env _server_workspace_ mailman.yaml start_mailman.sh +mailserver*.tgz +VERSION diff --git a/README.md b/README.md index f93a725..3dc1626 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/release-files.txt b/release-files.txt new file mode 100644 index 0000000..444b125 --- /dev/null +++ b/release-files.txt @@ -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 diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..cfc3a5e --- /dev/null +++ b/release.sh @@ -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" diff --git a/start_mailserver.sh b/start_mailserver.sh index d68605c..13a2c83 100755 --- a/start_mailserver.sh +++ b/start_mailserver.sh @@ -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 @@ -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}"