我是 gitlab 的新手,我有一个 python 包,我想为它自动化下一个版本。我想拥有:
- master 上的合并 => 创建一个新的次要版本
- 一个标签 => 创建一个新的主要版本。
我需要帮助才能做到这一点。我的.gitlab-ci.yml
文件是否正确?如何创建这个标签?我应该如何写我的提交信息?以及部署后我可以在哪里找到新版本参考。
我们在 github flow 中工作,有一个 features 分支和一个 master 分支。(没有 dev、prod、uat..etc 分支)
.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
安装程序.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',
)