]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Release: Tag script with all checks
authorMaria Matejka <mq@ucw.cz>
Thu, 11 Dec 2025 10:07:52 +0000 (11:07 +0100)
committerMaria Matejka <mq@ucw.cz>
Tue, 7 Apr 2026 09:51:05 +0000 (11:51 +0200)
This commit also allows running from a different repository, so that we
can test the release process without mingling with the public one.

.gitlab-ci.yml
gitlab/template.yml.j2
tools/git-check-tag-ci
tools/release-tag [new file with mode: 0755]
tools/release.py

index 92cafec4da74dfc7e3da2dadc8553b9f76a0c46e..225193712df4955447311f6bce2fa05e9459a562 100644 (file)
@@ -89,6 +89,7 @@ variables:
   IMG_BASE: registry.nic.cz/labs/bird
   TOOLS_DIR: /home/gitlab-runner/bird-tools
   STAYRTR_BINARY: /usr/local/bin/stayrtr
+  GITLAB_API_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/
 
 stages:
   - consistency
@@ -178,6 +179,7 @@ pipeline-infodump:
     echo "\$CI_COMMIT_MESSAGE = $CI_COMMIT_MESSAGE"
     echo "\$CI_PIPELINE_SOURCE = $CI_PIPELINE_SOURCE"
     echo "\$CI_MERGE_REQUEST_IID = $CI_MERGE_REQUEST_IID"
+    echo "\$GITLAB_API_URL = $GITLAB_API_URL"
     echo "\$wf_kind = $wf_kind"
     echo
     echo "### Inputs ###"
index 73071aa1a14989cd9072228a4fc00e03ae7d8152..dfd1b9067eb3825503a133ea08ecfb2ae220b1b5 100644 (file)
@@ -51,6 +51,7 @@ variables:
   IMG_BASE: registry.nic.cz/labs/bird
   TOOLS_DIR: /home/gitlab-runner/bird-tools
   STAYRTR_BINARY: /usr/local/bin/stayrtr
+  GITLAB_API_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/
 
 stages:
   - consistency
@@ -163,6 +164,7 @@ pipeline-infodump:
   "CI_COMMIT_MESSAGE",
   "CI_PIPELINE_SOURCE",
   "CI_MERGE_REQUEST_IID",
+  "GITLAB_API_URL",
   "wf_kind",
 ] %}
     echo "\${{ VAR }} = ${{ VAR }}"
index 0b7a442710617972ec75d019b3730e8f2eb57adf..df636f4c172eefeced251d6f79f3fc059c957c00 100755 (executable)
@@ -2,14 +2,28 @@
 
 import io
 import json
+import os
 import requests
 import sys
 import zipfile
 
+try:
+    GITLAB_API_URL = os.environ["GITLAB_API_URL"]
+except KeyError:
+    GITLAB_API_URL = "https://gitlab.nic.cz/api/v4/projects/labs%2Fbird/"
+
+try:
+    GITLAB_HEADERS = { "JOB-TOKEN": os.environ["CI_JOB_TOKEN"] }
+except KeyError:
+    GITLAB_HEADERS = {}
+
+artifacts = (sys.argv[1] != "--no-artifacts")
+ref = sys.argv[1] if artifacts else sys.argv[2]
+
 def load_api_request(name, query):
     timeout = 5
     while True:
-        resp = requests.get("https://gitlab.nic.cz/api/v4/projects/labs%2Fbird/" + query)
+        resp = requests.get(GITLAB_API_URL + query, headers=GITLAB_HEADERS)
         if resp.status_code == 200:
             return resp.content
 
@@ -45,7 +59,7 @@ def load_pipelines(sha):
 def load_jobs(pipeline):
     return load_paginated("jobs", f"/pipelines/{pipeline}/jobs/")
 
-for p in load_pipelines(sys.argv[1]):
+for p in load_pipelines(ref):
     if p['status'] in ("failed", "cancelled"):
         print(f"Pipeline {p['id']} {p['status']} at {p['web_url']}")
         failed = [ job for job in load_jobs(p['id']) if job['status'] == "failed" ]
@@ -81,9 +95,12 @@ for p in load_pipelines(sys.argv[1]):
                 print(f"\t{ job['name'] }:")
             for f in job['artifacts']:
                 if f['file_type'] == 'archive':
-                    with zipfile.ZipFile(io.BytesIO(load_api_request("metadata", f"/jobs/{job['id']}/artifacts/"))) as z:
-                        z.extractall()
+                    if artifacts:
+                        with zipfile.ZipFile(io.BytesIO(load_api_request("metadata", f"/jobs/{job['id']}/artifacts/"))) as z:
+                            z.extractall()
+                    else:
+                        print("\t\thas artifacts")
         exit(0)
 
-print("No suitable pipeline found, tag not OK")
+print(f"No suitable pipeline found for { ref }, tag not OK")
 exit(1)
diff --git a/tools/release-tag b/tools/release-tag
new file mode 100755 (executable)
index 0000000..6433a68
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+set -e
+
+toplevel=$(readlink -f $(dirname $0)/..)
+current_version=$(<$toplevel/VERSION)
+
+pushd $toplevel > /dev/null
+
+# Enforce tag eligibility
+tools/git-check-tag-local
+
+# Download built packages
+tools/git-check-tag-ci --no-artifacts $(git rev-parse HEAD)
+
+# Create the tag
+echo ">>> git tag -sam v$current_version v$current_version"
+GPG_TTY=$(tty) git tag -sam v$current_version v$current_version
+
+# Further instructions
+echo "Created tag v$current_version. You should manually check it."
+echo "    git show v$current_version"
+echo
+echo "Then you probably want to push it."
+echo "    git push origin $current_version."
index 62a404c74a2665668348a8f90060fed32b1ed483..7e0d849314906ac9607e771ab23ccbd464f897da 100755 (executable)
@@ -201,7 +201,12 @@ class GitlabException(Exception):
 
 # A singleton class providing raw Gitlab API
 class Gitlab:
-    stem = "https://gitlab.nic.cz/api/v4/projects/labs%2Fbird/"
+    def __init__(self):
+        try:
+            self.stem = os.environ["GITLAB_API_URL"]
+        except KeyError:
+            self.stem = "https://gitlab.nic.cz/api/v4/projects/labs%2Fbird/"
+
     def get(self, uri):
         response = requests.get(self.stem + uri, headers={"PRIVATE-TOKEN": git.token()})
         if not response.ok: