From eab22fd8be2c5359d3ec2d0dd266d582da2bebab Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Sat, 7 Jan 2023 21:09:42 +0100
Subject: [PATCH] [ci] Added job publish.

---
 .gitlab-ci.yml |  8 ++++++++
 tox.ini        | 14 ++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6eb365268..99fe5d5fb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -33,3 +33,11 @@ tests (arch):
 tests:
   script:
     - tox -p
+
+publish:
+  rules:
+    - if: $CI_COMMIT_TAG
+  variables:
+    TWINE_REPOSITORY: testpypi
+  script:
+    - tox -e publish
diff --git a/tox.ini b/tox.ini
index 4b4dc318e..6cfbcbc56 100644
--- a/tox.ini
+++ b/tox.ini
@@ -41,6 +41,20 @@ deps = pre-commit
 skip_install = True
 commands = pre-commit run --all-files
 
+[testenv:publish]
+deps =
+    build
+    twine
+skip_install = True
+passenv =
+    TWINE_REPOSITORY
+    TWINE_USERNAME
+    TWINE_PASSWORD
+commands =
+    pyproject-build
+    twine upload dist/*
+
+# Tool settings
 [pytest]
 testpaths = ogstools
 xfail_strict = true
-- 
GitLab