Commit ec4fd8cf authored by Adrien Oliva's avatar Adrien Oliva

ci(release): Compute release version in Pipeline

parent 73f9dbcb
Pipeline #813 passed with stages
in 4 minutes and 52 seconds
......@@ -97,6 +97,7 @@ build:
tags:
- docker
script:
- sed -i "s|__version__ = '[^']*'|__version__ = '$(python ./setversion.py $(git describe --tags --always) | cut -d'+' -f1)'|" openbudget/__init__.py
- make dist
artifacts:
paths:
......@@ -107,9 +108,22 @@ upload:
tags:
- docker
script:
- pip install twine
- twine upload --repository pypi dist/* --username $PYPI_USER --password $PYPI_PASS
dependencies:
- build
only:
- tags
upload_master:
stage: deploy
tags:
- docker
script:
- pip install twine
- twine upload --repository pypi dist/* --username $PYPI_USER --password $PYPI_PASS
dependencies:
- build
only:
refs:
- master
......@@ -24,6 +24,6 @@ import configparser
__author__ = "Yapbreak"
__email__ = 'yapbreak@yapbreak.fr'
__version__ = '0.0.2'
__version__ = '9.9.9'
__config__ = configparser.ConfigParser()
......@@ -21,9 +21,10 @@
Package definition of OpenBudget
"""
from setuptools import setup
import openbudget
VERSION = "0.0.2"
VERSION = openbudget.__version__
with open('README.rst') as readme_file:
README = readme_file.read()
......
#!/usr/bin/env python
# coding: utf-8
# Simple budget management planner
# Copyright (C) 2020 Yapbreak
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
Tool module to parse version string and format it to PEP440
"""
import sys
class Version:
"""
Format version number class
"""
@staticmethod
def get_at(list_, index, default):
"""
Get item in a list at index and fallback on default if not available
"""
try:
return list_[index]
except IndexError:
return default
def __init__(self, version):
self.original = version
self.version = version
if version[0] == 'v':
self.version = version[1:]
dot_split = self.version.split('.')
if len(dot_split) == 1:
dot_split = ['0', '0', '2-0-g{}'.format(self.version)]
self.major = self.get_at(dot_split, 0, '0')
self.minor = self.get_at(dot_split, 1, '0')
dash_split = self.get_at(dot_split, 2, '0').split('-')
self.patch = self.get_at(dash_split, 0, '0')
if 'rc' in self.patch:
release_split = self.patch.split('rc')
self.patch = release_split[0]
self.release = release_split[1]
else:
self.release = None
self.dev = self.get_at(dash_split, 1, None)
self.commit = self.get_at(dash_split, 2, None)
def __str__(self):
pep440_version = '{}.{}.{}'.format(
self.major, self.minor, self.patch
)
if self.release is not None:
pep440_version += '.rc{}'.format(self.release)
if self.dev is not None:
pep440_version += '.dev{}'.format(self.dev)
if self.commit is not None:
pep440_version += '+{}'.format(self.commit)
return pep440_version
if __name__ == '__main__':
VERS = Version(sys.argv[1])
print(VERS)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment