From 2ac252861bd66c15b5742ce7d21662b8a406cf35 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sat, 23 May 2020 02:27:49 +0200
Subject: [PATCH] Rework CI setup

Getting rid of the old build & build-master CI setup and replace it with
a more advanced setup using the new si-tools to manage release images.

It also introduces release versions for build-ah-engine which should
become handy in the future.
---
 .gitlab-ci.yml | 33 +++++++++++++++++++--------------
 Dockerfile     |  4 +++-
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cfceb61..bfa06ba 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,25 +1,30 @@
-# Official docker image.
 image: quay.io/sheogorath/build-ah-engine
 
+stages:
+  - analyse
+  - build
+  - test
+  - tag
+  - deploy
+
 before_script:
   - podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
 
-build-master:
-  stage: build
-  script:
-    - podman build --pull -t "$CI_REGISTRY_IMAGE" .
-    - podman push "$CI_REGISTRY_IMAGE"
-  only:
-    - master
-  tags:
-    - docker
+variables:
+  BAE_VERSION: "1.0.0"
+  SI_TOOLS_VERSION: "0.2.0"
 
 build:
   stage: build
   script:
-    - podman build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
+    - podman build --pull --build-arg SI_TOOLS_VERSION -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
     - podman push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
-  except:
+
+tagging-master:
+  stage: tag
+  script:
+    - podman pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
+    - si-tagging -l "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE" "${BAE_VERSION}"
+    - si-push "$CI_REGISTRY_IMAGE"
+  only:
     - master
-  tags:
-    - docker
diff --git a/Dockerfile b/Dockerfile
index 82f77c2..aa6ef1a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,12 +2,14 @@ FROM fedora:31
 
 COPY resources/storage.conf /etc/containers/
 
+ARG SI_TOOLS_VERSION=master
+
 RUN true\
    && dnf -y upgrade \
    && dnf -y install podman buildah findutils git \
    && dnf clean all \
    && sed -e 's/cgroup_manager =.*/cgroup_manager = "cgroupfs"/' /usr/share/containers/libpod.conf > /etc/containers/libpod.conf \
-   && git clone https://git.shivering-isles.com/shivering-isles/shell-tools.git ./shell-tools \
+   && git clone -b "$SI_TOOLS_VERSION" --depth=3 https://git.shivering-isles.com/shivering-isles/shell-tools.git ./shell-tools \
    && ./shell-tools/install.sh \
    && rm -rf ./shell-tools \
    && true
-- 
GitLab