phase1: support creating tags on demand
authorJo-Philipp Wich <jo@mein.io>
Mon, 28 Nov 2016 18:36:18 +0000 (19:36 +0100)
committerJo-Philipp Wich <jo@mein.io>
Mon, 28 Nov 2016 18:36:18 +0000 (19:36 +0100)
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 <jo@mein.io>
phase1/master.cfg

index bbed0543df32a53d4731cfc1052e8ca80474445a..f8b11df733a9644ccd97cea6d6d651e76c4ea37b 100644 (file)
@@ -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",