diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ad621f9..80d85690 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -197,16 +197,15 @@ semver: - git fetch --tags - git tag - # build - - pip install python-semantic-release==7.* wheel + # build and publish package + - pip install python-semantic-release==9.* wheel build twine - export GL_TOKEN=$CI_UPDATES - - export REPOSITORY_USERNAME=__token__ - - export REPOSITORY_PASSWORD=$CI_PYPI_TOKEN - - > - semantic-release publish -v DEBUG - -D version_variable=./setup.py:__version__ - -D hvcs=gitlab - -D branch=main + - semantic-release -vv version + + # check if any artifacts were created + - if [ ! -d dist ]; then echo No release will be made; exit 0; fi + - twine upload dist/* -u __token__ -p $CI_PYPI_TOKEN --skip-existing + - semantic-release publish allow_failure: false rules: diff --git a/pyproject.toml b/pyproject.toml index 7aa56e32..579544fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,3 +55,40 @@ profile = "black" line_length = 100 multi_line_output = 3 include_trailing_comma = true + +[tool.semantic_release] +build_command = "python -m build" +version_toml = ["pyproject.toml:project.version"] + +[tool.semantic_release.commit_author] +env = "GIT_COMMIT_AUTHOR" +default = "semantic-release " + +[tool.semantic_release.commit_parser_options] +allowed_tags = [ + "build", + "chore", + "ci", + "docs", + "feat", + "fix", + "perf", + "style", + "refactor", + "test", +] +minor_tags = ["feat"] +patch_tags = ["fix", "perf"] +default_bump_level = 0 + +[tool.semantic_release.remote] +name = "origin" +type = "gitlab" +ignore_token_for_push = false + +[tool.semantic_release.remote.token] +env = "GL_TOKEN" + +[tool.semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true