I am new on gitlab and I have a python package for which I want to automate the next releases. I would like to have for :
- A merge on master => creates a new minor version
- A tag => creates a new major version.
I need a help to do this. does my .gitlab-ci.yml
file is correct ? how a can create this tags ? how I should write my commit messages ? and where I can found the new version references after deployement.
We are working here in github flow, with a features branch and a master branch. (no dev, prod, uat..etc branch)
.gitlab-ci.yml
image: python:latest
stages:
- test
- tag
- deploy
before_script:
- pip install -r requirements.txt
test:
stage: test
script:
- pytest -vv
tag:
stage: tag
script:
- pip install twine bump2version
- bump2version release
- python setup.py sdist bdist_wheel
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --verbose --skip-existing --repository-url https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/*
only:
- tags
deploy:
stage: deploy
script:
- pip install twine bump2version
- bump2version minor
- python setup.py sdist bdist_wheel
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --verbose --skip-existing --repository-url https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/*
only:
- master
pages:
stage: deploy
script:
- pip install -U sphinx
- sphinx-build -b html source public
artifacts:
paths:
- public
only:
- master
setup.py
import setuptools
setuptools.setup(
name="myApp", # Replace with your own username
version="0.0.1",
author="name NAME",
author_email="name@email.com",
description="my new Application",
packages=setuptools.find_packages(),
install_requires=[
"google-auth==1.24.0",
"pydantic==1.7.3",
"email-validator==1.1.2",
"pytest-mock==3.3.1"
],
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)