From 4c5fdcbcca6065a2a7a986f8cb3d956165295309 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 28 Nov 2016 19:36:18 +0100 Subject: [PATCH] phase1: support creating tags on demand If a build is forcibly invoked with a custom tag=x.y.z property, the builder will prepare and push the appropriate Git repository tag. Signed-off-by: Jo-Philipp Wich --- phase1/master.cfg | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/phase1/master.cfg b/phase1/master.cfg index bbed054..f8b11df 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -174,6 +174,16 @@ def IsCleanRequested(pattern): return CheckCleanProperty +def IsTaggingRequested(step): + val = step.getProperty("tag") + if val and re.match("^[0-9]+\.[0-9]+\.[0-9]+$", val): + return True + else: + return False + +def IsNoTaggingRequested(step): + return not IsTaggingRequested(step) + c['builders'] = [] @@ -273,6 +283,26 @@ for target in targets: doStepIf = IsCleanRequested(tuple[0]) )) + factory.addStep(MasterShellCommand( + name = "maketag", + description = "Tagging Git repository", + command = [home_dir+'/maketag.sh', '-i', '-k', str(gpg_keyid or ''), + '-p', str(gpg_passfile or ''), '-v', WithProperties("%(tag:-)s")], + path = home_dir+'/source.git', + env = {'GNUPGHOME': gpg_home}, + haltOnFailure = True, + doStepIf = IsTaggingRequested + )) + + # switch to branch + factory.addStep(ShellCommand( + name = "switchbranch", + description = "Checking out Git branch", + command = ["git", "checkout", repo_branch], + haltOnFailure = True, + doStepIf = IsNoTaggingRequested + )) + # check out the source factory.addStep(Git( repourl = repo_url, @@ -280,6 +310,24 @@ for target in targets: mode = 'incremental', method = 'clean')) + # fetch tags + factory.addStep(ShellCommand( + name = "fetchtag", + description = "Fetching Git tags", + command = ["git", "fetch", "--tags", "--", repo_url], + haltOnFailure = True, + doStepIf = IsTaggingRequested + )) + + # switch to tag + factory.addStep(ShellCommand( + name = "switchtag", + description = "Checking out Git tag", + command = ["git", "checkout", WithProperties("tags/v%(tag:-)s")], + haltOnFailure = True, + doStepIf = IsTaggingRequested + )) + factory.addStep(ShellCommand( name = "rmtmp", description = "Remove tmp folder", -- 2.30.2