From e456b964f3196aa3076eac079adab708b857a44e Mon Sep 17 00:00:00 2001
From: Bert Palm <bert.palm@ufz.de>
Date: Thu, 27 Jul 2023 12:57:31 +0200
Subject: [PATCH] rolling release pipeline

---
 .gitlab-ci.yml | 15 +++++++++++++++
 setup.py       | 18 ++++++++++++++++--
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5e5ab6017..3f3f1e5ec 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -179,6 +179,21 @@ docs:
 # Extra Pipeline (run with a successful run of all other jobs on develop)
 # ===========================================================
 
+testpypi:
+  stage: deploy
+  only:
+    - develop
+  except:
+    - schedules
+  variables:
+    RELEASE: DEVELOP
+    TESTPYPI_USER: __token__
+    TESTPYPI_USER: __token__
+  script:
+    - pip install build twine
+    - python -m build
+    - twine upload -r testpypi -u __token__ -p $TESTPYPI_USER dist/*
+
 # make html docu with sphinx
 pages:
   stage: deploy
diff --git a/setup.py b/setup.py
index f81576440..f38a0d8af 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,6 @@
 # SPDX-FileCopyrightText: 2021 Helmholtz-Zentrum für Umweltforschung GmbH - UFZ
 # SPDX-License-Identifier: GPL-3.0-or-later
+import os
 
 import versioneer
 from setuptools import find_packages, setup
@@ -10,9 +11,22 @@ from setuptools import find_packages, setup
 with open("README.md", "r") as fh:
     long_description = fh.read()
 
+
+if os.environ.get("RELEASE") == "DEVELOP":
+    name = "saqc-dev"
+else:
+    name = "saqc"
+
+version = versioneer.get_version()
+
+if "dirty" in version:
+    raise ValueError(
+        f"The repository you build is dirty. Please commit changes first. {version=}"
+    )
+
 setup(
-    name="saqc",
-    version=versioneer.get_version(),
+    name=name,
+    version=version,
     cmdclass=versioneer.get_cmdclass(),
     author="Bert Palm, David Schaefer, Florian Gransee, Peter Luenenschloss",
     author_email="david.schaefer@ufz.de",
-- 
GitLab