From 258656fbf9c929cffa2033986c6cd5fcea43dade Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Tue, 15 Sep 2020 12:12:51 +0100 Subject: [PATCH] version based on current tag for makefile if there isnt a tag, version is 'git'. this fixes versioning for aur package and docker. --- Makefile | 2 +- version.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5e903ed..a8b8b40 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ mail: python3 mail/generate.py version: - python3 version.py git version.go + python3 version.py auto version.go compile: echo "Downloading deps" diff --git a/version.py b/version.py index 0b861b5..387e23e 100644 --- a/version.py +++ b/version.py @@ -6,6 +6,13 @@ try: except IndexError: version = "git" +if version == "auto": + try: + version = subprocess.check_output("git describe --exact-match HEAD".split()).decode("utf-8").rstrip().replace('v', '') + except subprocess.CalledProcessError as e: + if e.returncode == 128: + version = "git" + commit = subprocess.check_output("git rev-parse --short HEAD".split()).decode("utf-8").rstrip() file = f'package main; const VERSION = "{version}"; const COMMIT = "{commit}";'