From a9b618929091876e5988d6a83e191543873c9f3b Mon Sep 17 00:00:00 2001
From: Christian Boettcher <c.boettcher@fz-juelich.de>
Date: Mon, 13 Dec 2021 07:44:36 +0100
Subject: [PATCH] only build on release

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

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1d23e80..8995f98 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -40,9 +40,13 @@ test_package:
 
 build_package:
   stage: build
+  only:
+    variables:
+      - $CI_COMMIT_TAG =~ /release/
   script:
     - pip install -r requirements.txt
-    - sed -i "s_VERSION_0.0.1_g" setup.cfg
+    - VER=${CI_COMMIT_TAG#*-}
+    - sed -i "s_VERSION_${VER}_g" setup.cfg
     - python -m build
   artifacts:
     paths:
@@ -56,6 +60,4 @@ publish_package:
   stage: publish
   script:
     - pip install twine
-    - VER=${CI_COMMIT_TAG#*-}
-    - sed -i "s_VERSION_${VER}_g" setup.cfg
     - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
-- 
GitLab