Handle version numbers with suffix and no hyphen. Add support for ENV using the recommended syntax with =

This commit is contained in:
Magnus Walbeck 2021-07-01 12:54:21 +02:00
parent 537b4058d6
commit 2fab6d75f5
Signed by: mwalbeck
GPG key ID: CCB78CFF3F950769
3 changed files with 11 additions and 2 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@ __pycache__
.pytest_cache
.coverage
dist
Dockerfile.test
.tags

View file

@ -79,13 +79,20 @@ def main():
with open(dockerfile_path) as dockerfile:
for line in dockerfile:
if re.search(rf"ENV {app_name}_VERSION .*", line):
if re.search(rf"ENV {app_name}_VERSION=.*", line):
version_string = line[line.find("=", 4) + 1 :].strip()
break
elif re.search(rf"ENV {app_name}_VERSION .*", line):
version_string = line[line.find(" ", 4) + 1 :].strip()
break
if version_string[0] == "v":
version_string = version_string[1:]
if "-" not in version_string and re.search(r"\d*\.\d*\.\d*\w*", version_string):
split_version_string = re.split(r"(\d*\.\d*\.\d*)(\w*.*)", version_string)
version_string = split_version_string[1] + "-" + split_version_string[2]
tags = determine_tags(version_string, app_env, include_major, include_suffix)
elif version_type == "docker_from":

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "determine-docker-tags"
version = "0.1.6"
version = "0.1.7"
description = "A small program to determine docker image tags"
authors = ["Magnus Walbeck <magnus.walbeck@walbeck.it>"]
readme = "README.md"