From db5325a5c05b0739bc3951b7232455ce7c6a8bbe Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo@trentesaux.fr>
Date: Fri, 7 Jul 2023 18:57:48 +0200
Subject: [PATCH] WIP improve CI

---
 .gitlab-ci.yml | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fa06a4d..d5d6100 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,10 +3,16 @@
 image: "rust:latest"
 
 stages:
-  - build
+  - build_stage
+  - upload_stage
+  - release_stage
 
-build:
+# build gcli binary
+build_stage:
   stage: build
+  # only build gcli when adding a tag
+  only:
+    - tags
   # image used for this build
   image: rust
   # build script
@@ -23,6 +29,29 @@ build:
           - Cargo.lock
       paths:
         - target/release
-  # only build gcli when adding a tag
-  only:
-    - tags
\ No newline at end of file
+
+# upload gcli binary to gitlab
+upload_stage:
+  stage: upload
+  image: curlimages/curl:latest
+  rules:
+    - if: $CI_COMMIT_TAG
+  script:
+    - |
+      curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/release/gcli "${PACKAGE_REGISTRY_URL}/gcli"
+
+# create a gitlab release pointing to this binary
+release_stage:
+  stage: release
+  image: registry.gitlab.com/gitlab-org/release-cli:latest
+  script:
+    - echo "Running the release job."
+  release:
+    tag_name: $CI_COMMIT_TAG
+    name: 'Release $CI_COMMIT_TAG'
+    description: 'Automated release for $CI_COMMIT_TAG'
+    assets:
+      links:
+        - name: 'gcli'
+          link_type: binary
+          url: "${PACKAGE_REGISTRY_URL}/gcli"
\ No newline at end of file
-- 
GitLab