diff mbox series

[yocto-autobuilder-helper,v2] prepare-shared-repos: Allow to tag poky git

Message ID 20241118101353.385834-1-mathieu.dubois-briand@bootlin.com
State New
Headers show
Series [yocto-autobuilder-helper,v2] prepare-shared-repos: Allow to tag poky git | expand

Commit Message

Mathieu Dubois-Briand Nov. 18, 2024, 10:13 a.m. UTC
From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
 scripts/prepare-shared-repos | 6 ++++++
 scripts/utils.py             | 8 ++++++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/scripts/prepare-shared-repos b/scripts/prepare-shared-repos
index 1b756520b701..3d10af4e6d63 100755
--- a/scripts/prepare-shared-repos
+++ b/scripts/prepare-shared-repos
@@ -16,6 +16,7 @@  import tempfile
 
 import utils
 
+poky_tag_remote = "git@push.yoctoproject.org:poky-ci-archive"
 
 parser = utils.ArgParser(description='Iterates over a set of repositories in a json file and sets up a shared directory containing them.')
 
@@ -26,6 +27,9 @@  parser.add_argument('sharedsrcdir',
 parser.add_argument('-p', '--publish-dir',
                     action='store',
                     help="Where to publish artefacts to (optional)")
+parser.add_argument('-t', '--tag',
+                    action='store',
+                    help="Git tag to create (optional)")
 
 args = parser.parse_args()
 
@@ -49,6 +53,8 @@  with tempfile.TemporaryDirectory(prefix="shared-repo-temp-", dir="/home/pokybuil
             utils.fetchgitrepo(tempdir, repo, repos[repo], stashdir, depth=1)
         if args.publish_dir:
             utils.publishrepo(tempdir, repo, args.publish_dir)
+        if repo == "poky" and args.tag:
+            utils.taggitrepo(tempdir, repo, repos[repo], poky_tag_remote, args.tag)
 
     utils.printheader("Creating shared src tarball")
     subprocess.check_call("tar -I zstd -cf " + args.sharedsrcdir.rstrip("/") + ".tar.zst ./*", shell=True, cwd=tempdir)
diff --git a/scripts/utils.py b/scripts/utils.py
index 8e6463d8c62c..2902dfa9fcd5 100644
--- a/scripts/utils.py
+++ b/scripts/utils.py
@@ -280,6 +280,14 @@  def fetchgitrepo(clonedir, repo, params, stashdir, depth=None):
     subprocess.check_call(["git", "reset", "origin/" + branch, "--hard"], cwd=sharedrepo)
     subprocess.check_call(["git", "reset", revision, "--hard"], cwd=sharedrepo)
 
+def taggitrepo(clonedir, repo, params, tagremote, tagname):
+    sharedrepo = "%s/%s" % (clonedir, repo)
+    revision = params["revision"]
+    print("Creating tag...")
+    subprocess.check_call(["git", "tag", tagname, revision], cwd=sharedrepo)
+    print("Pushing tag...")
+    subprocess.check_call(["git", "push", tagremote, tagname], cwd=sharedrepo)
+
 def publishrepo(clonedir, repo, publishdir):
     sharedrepo = "%s/%s" % (clonedir, repo)
     revision = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=sharedrepo).decode('utf-8').strip()