From 67bc0ebc204bcea7993ba1cb8d415977ec15c6c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me>
Date: Wed, 6 Mar 2024 20:18:42 +0100
Subject: [PATCH] CI/CD => Bug fix: On sign stage export only the current
 binaries folder

---
 NodeApp/.gitlab-ci/00_vars.yml            |  2 +-
 NodeApp/.gitlab-ci/02_templates.yml       |  6 +++---
 NodeApp/.gitlab-ci/06_stageBuild.yml      |  2 +-
 NodeApp/.gitlab-ci/07_stagePkgAndSign.yml | 22 ++++++++++++++++------
 NodeApp/.gitlab-ci/09_stageUpload.yml     |  1 +
 5 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/NodeApp/.gitlab-ci/00_vars.yml b/NodeApp/.gitlab-ci/00_vars.yml
index 642e2de..bab6ab5 100644
--- a/NodeApp/.gitlab-ci/00_vars.yml
+++ b/NodeApp/.gitlab-ci/00_vars.yml
@@ -30,7 +30,7 @@ variables:
     BIN_FOLDER_WINDOWS_ARM64: $BIN_FOLDER_WINDOWS/arm64
     BIN_FOLDER_WINDOWS_X64: $BIN_FOLDER_WINDOWS/x64
 
-    VERSION_FILE: $ARTIFACTS_FOLDER/VERSION
+    CONFIG_FILE: $ARTIFACTS_FOLDER/CONFIG.env
     VERSION_DEV_SUFFIX: '-dev'
     VERSION_TEST_SUFFIX: '-test'
 
diff --git a/NodeApp/.gitlab-ci/02_templates.yml b/NodeApp/.gitlab-ci/02_templates.yml
index 828f273..6db2a93 100644
--- a/NodeApp/.gitlab-ci/02_templates.yml
+++ b/NodeApp/.gitlab-ci/02_templates.yml
@@ -53,7 +53,7 @@
         - rm -Rf ${PKG_BUILD_FOLDER_NAME}
     artifacts:
         paths:
-            - $ARTIFACTS_FOLDER/*
+            - $BIN_FOLDER_DEBIAN_PKG_AND_SIGN/*
         expire_in: 10 mins
     rules:
         -   if: $CI_COMMIT_REF_PROTECTED == "true"
@@ -66,7 +66,7 @@
     dependencies:
         - build:version
     script:
-        - VERSION=$(cat $VERSION_FILE)
+        - source $CONFIG_FILE
         - !reference [ .get_version_dependent_vars, script ]
 
         - security unlock-keychain -p $SIGN_KEYCHAIN_PASSWORD $SIGN_LOGIN_KEYCHAIN_PATH
@@ -87,7 +87,7 @@
         - rm -Rf ${BIN_NAME_BASE}_pkg
     artifacts:
         paths:
-            - $ARTIFACTS_FOLDER/*
+            - $BIN_FOLDER_MACOS_PKG_AND_SIGN/*
         expire_in: 10 mins
     rules:
         -   if: $CI_COMMIT_REF_PROTECTED == "true"
\ No newline at end of file
diff --git a/NodeApp/.gitlab-ci/06_stageBuild.yml b/NodeApp/.gitlab-ci/06_stageBuild.yml
index 322912d..4526065 100644
--- a/NodeApp/.gitlab-ci/06_stageBuild.yml
+++ b/NodeApp/.gitlab-ci/06_stageBuild.yml
@@ -10,7 +10,7 @@ build:version:
         - !reference [ .get_version_dependent_vars, script ]
 
         - mkdir -p $ARTIFACTS_FOLDER
-        - echo $VERSION > $VERSION_FILE
+        - echo "VERSION=${VERSION}" > $CONFIG_FILE
 
         # Build
         - !reference [ .build_cli, script ]
diff --git a/NodeApp/.gitlab-ci/07_stagePkgAndSign.yml b/NodeApp/.gitlab-ci/07_stagePkgAndSign.yml
index be2b3ba..ef8c4b8 100644
--- a/NodeApp/.gitlab-ci/07_stagePkgAndSign.yml
+++ b/NodeApp/.gitlab-ci/07_stagePkgAndSign.yml
@@ -1,20 +1,24 @@
 pkg_and_sign:debian:
     parallel:
         matrix:
-            -   ARCH: [ "arm64", "amd64" ]
+            -   ARCH: "arm64"
+                BIN_FOLDER_DEBIAN_PKG_AND_SIGN: $BIN_FOLDER_LINUX_ARM64
+            -   ARCH: "amd64"
+                BIN_FOLDER_DEBIAN_PKG_AND_SIGN: $BIN_FOLDER_LINUX_X64
     before_script:
         - !reference [ .global_before_script, script ]
-        - BIN_FOLDER_DEBIAN_PKG_AND_SIGN=$([[ $ARCH == "arm64" ]] && echo ${BIN_FOLDER_LINUX_ARM64} || echo ${BIN_FOLDER_LINUX_X64})
     extends: .pkg_and_sign:debian
 
 
 pkg_and_sign:debian:test:
     parallel:
         matrix:
-            -   ARCH: [ "arm64", "amd64" ]
+            -   ARCH: "arm64"
+                BIN_FOLDER_DEBIAN_PKG_AND_SIGN: $BIN_FOLDER_LINUX_ARM64
+            -   ARCH: "amd64"
+                BIN_FOLDER_DEBIAN_PKG_AND_SIGN: $BIN_FOLDER_LINUX_X64
     before_script:
         - !reference [ .global_before_script, script ]
-        - BIN_FOLDER_DEBIAN_PKG_AND_SIGN=$([[ $ARCH == "arm64" ]] && echo ${BIN_FOLDER_LINUX_ARM64} || echo ${BIN_FOLDER_LINUX_X64})
     extends: .pkg_and_sign:debian
     artifacts:
         expire_in: 2 weeks
@@ -25,14 +29,20 @@ pkg_and_sign:debian:test:
 pkg_and_sign:macos:
     parallel:
         matrix:
-            -   BIN_FOLDER_MACOS_PKG_AND_SIGN: [ "$BIN_FOLDER_MACOS_ARM64", "$BIN_FOLDER_MACOS_X64" ]
+            -   ARCH: "arm64"
+                BIN_FOLDER_MACOS_PKG_AND_SIGN: $BIN_FOLDER_MACOS_ARM64
+            -   ARCH: "amd64"
+                BIN_FOLDER_MACOS_PKG_AND_SIGN: $BIN_FOLDER_MACOS_X64
     extends: .pkg_and_sign:macos
 
 
 pkg_and_sign:macos:test:
     parallel:
         matrix:
-            -   BIN_FOLDER_MACOS_PKG_AND_SIGN: [ "$BIN_FOLDER_MACOS_ARM64", "$BIN_FOLDER_MACOS_X64" ]
+            -   ARCH: "arm64"
+                BIN_FOLDER_MACOS_PKG_AND_SIGN: $BIN_FOLDER_MACOS_ARM64
+            -   ARCH: "amd64"
+                BIN_FOLDER_MACOS_PKG_AND_SIGN: $BIN_FOLDER_MACOS_X64
     extends: .pkg_and_sign:macos
     artifacts:
         expire_in: 2 weeks
diff --git a/NodeApp/.gitlab-ci/09_stageUpload.yml b/NodeApp/.gitlab-ci/09_stageUpload.yml
index 7d50365..3cdbf6f 100644
--- a/NodeApp/.gitlab-ci/09_stageUpload.yml
+++ b/NodeApp/.gitlab-ci/09_stageUpload.yml
@@ -3,6 +3,7 @@ upload:packages:
     tags:
         - gitlab_package
     dependencies:
+        - build:version
         - pkg_and_sign:macos
         - pkg_and_sign:debian
     image: registry.gitlab.com/gitlab-ci-utils/curl-jq:latest
-- 
GitLab