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
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 ###"
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
"CI_COMMIT_MESSAGE",
"CI_PIPELINE_SOURCE",
"CI_MERGE_REQUEST_IID",
+ "GITLAB_API_URL",
"wf_kind",
] %}
echo "\${{ VAR }} = ${{ VAR }}"
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
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" ]
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)
--- /dev/null
+#!/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."
# 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: