Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include Global Configurations
include:
- project: 'api-server/gitlab-ci-scripts'
ref: v1.1
file: '.global-configuration.yml'

image: code.route360.net:4567/docker/general-image/service/psql9.6:0.0.4

stages:
- build
- deploy

build:
stage: build
script:
- configure_sonar_scanner
- configure_python3_virtual_env
- python3 -m compileall -f targomo_python deploy.py setup.py
- sonarscanner -Dsonar.sources=targomo_python
only:
- /^feature.*$/
- /^release.*$/
- develop
- master

deploy:
stage: deploy
script:
- configure_python3_virtual_env
- insert_pypirc
- echo $CI_COMMIT_TAG
- python3 deploy.py --version $CI_COMMIT_TAG
only:
- tags
14 changes: 5 additions & 9 deletions deploy.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
### publish new version of this library to PyPI

import git
from shutil import copyfile
import fileinput
import sys
import os
import argparse

parser = argparse.ArgumentParser(description="Publish the Targomo python library to PyPi")
parser.add_argument("--version", required=True, type=str, help="The version number", nargs="?")
args = parser.parse_args()

copyfile("./setup.py.default", "./setup.py")

repo = git.Repo(".")
lasttag = sorted(repo.tags, key=lambda t: t.commit.committed_date)[-1]
nexttag = "0." + str(int(str(lasttag).replace("0.", "")) + 1)

for line in fileinput.input("./setup.py", inplace=True):
line = line.replace("$VERSION", str(nexttag))
line = line.replace("$VERSION", args.version)
sys.stdout.write(line),

new_tag = repo.create_tag(str(nexttag), message='Automatic deployment of new version "{0}"'.format(nexttag))
repo.remotes.origin.push(new_tag)

os.system("python3 setup.py sdist")
os.system("twine upload --repository pypitest dist/*")
os.system("twine upload --repository pypi dist/*")