From 4cdfc120a2e531825be760b93819b3b4d2af0994 Mon Sep 17 00:00:00 2001
From: Maximilian Moser <maximilian.moser@tuwien.ac.at>
Date: Thu, 15 Jul 2021 14:39:13 +0200
Subject: [PATCH] Create CI/CD job for publishing on PyPI

* triggered by version tags
---
 .gitlab-ci.yml | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3e009c3..9cf3b63 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,3 +1,5 @@
+# vim: ts=2
+
 sonarqube-check:
   variables:
     SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
@@ -9,4 +11,15 @@ sonarqube-check:
   script:
     - sonar-scanner
   allow_failure: true
+  only:
+    - master
+    - merge_requests
 
+pypi-release:
+  rules:
+    - if: '$CI_COMMIT_TAG =~ /^v\d+/'
+  script:
+    - pip3 install --upgrade pip build twine
+    - rm -f dist/*
+    - python3 -m build
+    - TWINE_USERNAME=${PYPI_USER} TWINE_PASSWORD=${PYPI_PASSWORD} python3 -m twine upload --skip-existing --non-interactive dist/*
-- 
GitLab