From 92758e45a6aec418072f584cd90a5e2f287cdea2 Mon Sep 17 00:00:00 2001
From: Christian Boettcher <c.boettcher@fz-juelich.de>
Date: Mon, 13 Dec 2021 07:32:28 +0100
Subject: [PATCH] get version from release tag instead of manually

---
 .gitlab-ci.yml | 3 +++
 setup.cfg      | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 41a860a..1d23e80 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -42,6 +42,7 @@ build_package:
   stage: build
   script:
     - pip install -r requirements.txt
+    - sed -i "s_VERSION_0.0.1_g" setup.cfg
     - python -m build
   artifacts:
     paths:
@@ -55,4 +56,6 @@ 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/*
diff --git a/setup.cfg b/setup.cfg
index 0ffa976..c95882b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = airflow_datacat_integration
-version = 0.0.1
+version = VERSION
 author = Christian Boettcher
 author_email = c.boettcher@fz-juelich.de
 description = Datacatalog Integration for Apache Airflow
-- 
GitLab