From e147c4d525650026aaed1e5f485cab3bafc48c74 Mon Sep 17 00:00:00 2001
From: Juraj Paluba <492988@mail.muni.cz>
Date: Mon, 28 Mar 2022 18:11:20 +0200
Subject: [PATCH] create gitlab-ci

---
 .gitlab-ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..ce5f603
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,46 @@
+image: python:3.8
+
+variables:
+  PYTHON_TAG: py3
+  ABI_TAG: none
+  PLATFORM_TAG: any
+  PACKAGE_EXTENSION: whl
+
+stages:
+  - build
+  - deploy
+
+build:
+  stage: build
+  script:
+    # Get version. Variable CI_COMMIT_TAG is set only when tag was pushed.
+    - export VERSION=$(if [[ "$CI_COMMIT_TAG" == "" ]]; then echo 0.0.0; else echo $CI_COMMIT_TAG | cut -c 2-; fi)
+    - python3 setup.py setopt --command=metadata --option=version --set-value=$VERSION
+    - echo VERSION=$VERSION
+    # Get package filename
+    - export WHEEL_NAME=$(python3 setup.py --name | tr '-' '_')
+    - export PACKAGE=$WHEEL_NAME-$VERSION-$PYTHON_TAG-$ABI_TAG-$PLATFORM_TAG.$PACKAGE_EXTENSION
+    - echo PACKAGE=$PACKAGE
+    - python3 setup.py bdist_wheel
+    - echo $PACKAGE > dist/.package-name
+  only:
+    - branches
+    - tags
+  artifacts:
+    paths:
+      - dist
+    expire_in: 1 day
+
+deploy:
+  stage: deploy
+  variables:
+    TWINE_PASSWORD: '$CI_CUSTOM_REGISTRY_PASSWORD'
+    TWINE_USERNAME: '$CI_CUSTOM_REGISTRY_USER'
+  script:
+    - export PACKAGE=$(cat dist/.package-name)
+    - pip3 install twine
+    - python3 -m twine upload --repository-url $KYPO_PYPI_UPLOAD_URL dist/$PACKAGE
+  dependencies:
+    - build
+  only:
+    - tags
-- 
GitLab