Apply tags from the python

This commit is contained in:
Ayaz Salikhov
2021-03-20 21:02:21 +03:00
parent 9fe5186aba
commit ffbe758e54
5 changed files with 134 additions and 1 deletions

39
tagging/taggers.py Normal file
View File

@@ -0,0 +1,39 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from tagger_interface import TaggerInterface
from git_helper import GitHelper
from plumbum.cmd import docker
def _get_full_name(short_image_name, owner):
return f"{owner}/{short_image_name}:latest"
def _get_program_version(short_image_name, owner, program):
return docker[
"run",
"--rm",
"-a", "STDOUT",
_get_full_name(short_image_name, owner),
program, "--version"
]().strip()
class SHATagger(TaggerInterface):
@staticmethod
def tag_value(short_image_name, owner):
return GitHelper.commit_hash()[:12]
@staticmethod
def tag_name():
return "git_sha"
class PythonVersionTagger(TaggerInterface):
@staticmethod
def tag_value(short_image_name, owner):
return "python-" + _get_program_version(short_image_name, owner, "python").split()[1]
@staticmethod
def tag_name():
return "python_version"