From 0002705aa22716db026a90f6a899ef786efcbe35 Mon Sep 17 00:00:00 2001
From: Guilhem Bonnefille <guilhem.bonnefille@csgroup.eu>
Date: Tue, 27 Jun 2023 18:47:24 +0000
Subject: [PATCH] fix(publish): avoid rebuilding packages (optimization)

---
 templates/gitlab-ci-python.yml | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml
index 1e04d66..48254af 100644
--- a/templates/gitlab-ci-python.yml
+++ b/templates/gitlab-ci-python.yml
@@ -511,8 +511,11 @@ variables:
     then
       maybe_install_poetry
  
-      log_info "--- build packages (poetry)..."
-      poetry build ${TRACE+--verbose}
+      if [[ "$PYTHON_PACKAGE_ENABLED" != "true" ]]
+      then
+        log_info "--- build packages (poetry)..."
+        poetry build ${TRACE+--verbose}
+      fi
 
       log_info "--- publish packages (poetry)..."
       poetry config repositories.user_defined "$PYTHON_REPOSITORY_URL"
@@ -521,9 +524,12 @@ variables:
       # shellcheck disable=SC2086
       pip install ${PIP_OPTS} build twine
  
-      log_info "--- build packages (build)..."
-      rm -rf dist
-      python -m build
+      if [[ "$PYTHON_PACKAGE_ENABLED" != "true" ]]
+      then
+        log_info "--- build packages (build)..."
+        rm -rf dist
+        python -m build
+      fi
 
       log_info "--- publish packages (twine)..."
       twine upload ${TRACE+--verbose} --username "$PYTHON_REPOSITORY_USERNAME" --password "$PYTHON_REPOSITORY_PASSWORD" --repository-url "$PYTHON_REPOSITORY_URL" dist/*
-- 
GitLab