Add version info from git tags
This commit is contained in:
parent
2bf809c454
commit
9107474d31
3
Makefile
3
Makefile
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
shell:
|
shell:
|
||||||
MYPYPATH=`pipenv --venv`/lib/python3.11/site-packages pipenv shell
|
MYPYPATH=`pipenv --venv`/lib/python3.11/site-packages pipenv shell
|
||||||
|
|
||||||
@ -18,6 +16,7 @@ requirements.txt: Pipfile.lock
|
|||||||
build: clean requirements.txt
|
build: clean requirements.txt
|
||||||
python3 -m pip install -r requirements.txt --target build
|
python3 -m pip install -r requirements.txt --target build
|
||||||
cp -r mail4one/ build/
|
cp -r mail4one/ build/
|
||||||
|
sed -i "s/DEVELOMENT/$(shell scripts/get_version.sh)/" build/mail4one/version.py
|
||||||
python3 -m compileall build/mail4one -f
|
python3 -m compileall build/mail4one -f
|
||||||
rm -rf build/*.dist-info
|
rm -rf build/*.dist-info
|
||||||
python3 -m zipapp \
|
python3 -m zipapp \
|
||||||
|
@ -9,6 +9,7 @@ from getpass import getpass
|
|||||||
|
|
||||||
from .smtp import create_smtp_server_starttls, create_smtp_server
|
from .smtp import create_smtp_server_starttls, create_smtp_server
|
||||||
from .pop3 import create_pop_server
|
from .pop3 import create_pop_server
|
||||||
|
from .version import VERSION
|
||||||
|
|
||||||
from . import config
|
from . import config
|
||||||
from . import pwhash
|
from . import pwhash
|
||||||
@ -25,15 +26,17 @@ def setup_logging(cfg: config.LogCfg):
|
|||||||
if cfg.logfile == "STDOUT":
|
if cfg.logfile == "STDOUT":
|
||||||
logging.basicConfig(level=cfg.level, format=logging_format)
|
logging.basicConfig(level=cfg.level, format=logging_format)
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(filename=cfg.logfile, level=cfg.level, format=logging_format)
|
logging.basicConfig(filename=cfg.logfile,
|
||||||
|
level=cfg.level,
|
||||||
|
format=logging_format)
|
||||||
|
|
||||||
|
|
||||||
async def a_main(cfg: config.Config) -> None:
|
async def a_main(cfg: config.Config) -> None:
|
||||||
default_tls_context: ssl.SSLContext | None = None
|
default_tls_context: ssl.SSLContext | None = None
|
||||||
|
|
||||||
if tls := cfg.default_tls:
|
if tls := cfg.default_tls:
|
||||||
logging.info(f"Initializing default tls {tls.certfile=}, {tls.keyfile=}")
|
logging.info(
|
||||||
|
f"Initializing default tls {tls.certfile=}, {tls.keyfile=}")
|
||||||
default_tls_context = create_tls_context(tls.certfile, tls.keyfile)
|
default_tls_context = create_tls_context(tls.certfile, tls.keyfile)
|
||||||
|
|
||||||
def get_tls_context(tls: config.TLSCfg | str):
|
def get_tls_context(tls: config.TLSCfg | str):
|
||||||
@ -102,6 +105,7 @@ def main() -> None:
|
|||||||
description="Personal Mail Server",
|
description="Personal Mail Server",
|
||||||
epilog="See https://gitea.balki.me/balki/mail4one for more info",
|
epilog="See https://gitea.balki.me/balki/mail4one for more info",
|
||||||
)
|
)
|
||||||
|
parser.add_argument("-v", "--version", action="version", version=VERSION)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-e",
|
"-e",
|
||||||
"--echo_password",
|
"--echo_password",
|
||||||
@ -150,7 +154,7 @@ def main() -> None:
|
|||||||
else:
|
else:
|
||||||
cfg = config.Config(args.config.read_text())
|
cfg = config.Config(args.config.read_text())
|
||||||
setup_logging(config.LogCfg(cfg.logging))
|
setup_logging(config.LogCfg(cfg.logging))
|
||||||
logging.info(f"Starting mail4one {args.config=!s}")
|
logging.info(f"Starting mail4one {VERSION} {args.config=!s}")
|
||||||
asyncio.run(a_main(cfg))
|
asyncio.run(a_main(cfg))
|
||||||
|
|
||||||
|
|
||||||
|
2
mail4one/version.py
Normal file
2
mail4one/version.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
VERSION = "DEVELOMENT"
|
30
scripts/get_version.sh
Executable file
30
scripts/get_version.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
commit=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
# This is true if there is a tag on current HEAD
|
||||||
|
if git describe --exact-match > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
tag_val=$(git describe --dirty=DIRTY --exact-match)
|
||||||
|
case "$tag_val" in
|
||||||
|
*DIRTY)
|
||||||
|
echo "git=$commit-changes"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
v*) # Only consider tags starting with v
|
||||||
|
echo "$tag_val"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "git-$commit"
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
tag_val=$(git describe --dirty=DIRTY)
|
||||||
|
case "$tag_val" in
|
||||||
|
*DIRTY)
|
||||||
|
echo "git-$commit-changes"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "git-$commit"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user