Reputation: 31
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 :
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="[email protected]",
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',
)
Upvotes: 1
Views: 1827
Reputation: 1327334
A GitLab job has predefined environment variables which could be of interest when you are calling your script from your gitlab-ci.yml
.
And since GitLab 13.11 (April 2021), you now have:
Predefined CI/CD variable for commit author
Previously, if you needed to identify the author of a commit in a running CI/CD job, you had to add an extra API call to the job to retrieve it.
Now, this information is readily available as the
CI_COMMIT_AUTHOR
predefined CI/CD variable.Thanks to Craig Andrews for this contribution!
See Documentation and Issue.
That can help for your author
/author_email
variables, considering that variable is in the Name <email>
format.
Upvotes: 0