From 694d7d7ed986d660a61df212a1e4f800880dbc81 Mon Sep 17 00:00:00 2001
From: Thibault Debatty <t.debatty@cylab.be>
Date: Tue, 10 Jan 2023 14:51:56 +0100
Subject: [PATCH] add gitlab-ci

---
 .gitlab-ci.yml | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..c0ee194
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,66 @@
+stages:
+  - build
+  - release
+
+
+build:
+  image: docker:20.10.16
+  # run on a gitlab-runner that is configured with docker-in-docker
+  tags:
+    - dind
+  stage: build
+  except:
+    - tags
+  services:
+    - docker:20.10.16-dind
+  variables:
+    # use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
+    # mounts /certs directory for the service and build container
+    # needed for the Docker client to use the certificates
+    DOCKER_TLS_CERTDIR: "/certs"
+  before_script:
+    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+  script:
+    # use previous image as a cache to speedup build process
+    - docker pull $CI_REGISTRY_IMAGE:latest || true
+    - docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
+
+build:tagged:
+  image: docker:20.10.16
+  # run on a gitlab-runner that is configured with docker-in-docker
+  tags:
+    - dind
+  stage: build
+  # only for git tags
+  only:
+    - tags
+  services:
+    - docker:20.10.16-dind
+  variables:
+    # use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
+    # mounts /certs directory for the service and build container
+    # needed for the Docker client to use the certificates
+    DOCKER_TLS_CERTDIR: "/certs"
+  before_script:
+    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+  script:
+    # use previous image as a cache to speedup build process
+    - docker pull $CI_REGISTRY_IMAGE:latest || true
+    - echo $CI_COMMIT_TAG > public/VERSION
+    - docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --tag $CI_REGISTRY_IMAGE:latest .
+    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
+    - docker push $CI_REGISTRY_IMAGE:latest
+
+release:
+  stage: release
+  image: registry.gitlab.com/gitlab-org/release-cli:latest
+  rules:
+    - if: $CI_COMMIT_TAG                 # Run this job when a tag is created
+  script:
+    - echo "running release_job"
+  release:                               # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
+    tag_name: '$CI_COMMIT_TAG'
+    description: '$CI_COMMIT_TAG'
+
+
+
-- 
GitLab