From 71a55be5855fc55fc3cf9d7f8bb2b3008e570407 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1t=C3=A9=20Cser=C3=A9p?= <mcserep@gmail.com>
Date: Thu, 20 Jan 2022 12:42:21 +0100
Subject: [PATCH] Publish Windows binaries in CI and upload them to Package
 Registry.

---
 .gitlab-ci.yml | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8f87bec..f7c2ec3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,6 +5,7 @@ stages:
   - build
   - test_unix
   - test_win
+  - upload
 
 before_script:
   - dotnet --version
@@ -21,6 +22,12 @@ build_view:
   tags: [windows]
   script:
     - dotnet build CSIP-42.ThemePark.sln
+    - dotnet publish CSIP-42.ThemePark.View\CSIP-42.ThemePark.View.csproj -c Release -o publish
+  artifacts:
+    name: 'csip-42_binaries'
+    expire_in: 3 days
+    paths:
+      - publish
 
 
 test_construction_model:
@@ -51,3 +58,17 @@ test_simulation_model_win:
   script:
     - dotnet test CSIP-42.ThemePark.Model.Simulation.Test
 
+upload_binaries:
+  stage: upload
+  image: ubuntu:20.04
+  rules:
+    - if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v.*$/'
+  variables:
+    PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/windows-release/$CI_COMMIT_TAG"
+  before_script:
+    - apt-get update -y
+    - apt-get install -y zip curl
+  script:
+    - zip -r publish.zip publish/
+    - |
+      curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file publish.zip "${PACKAGE_REGISTRY_URL}/windows-release-$CI_COMMIT_TAG.zip"
\ No newline at end of file
-- 
GitLab