[ADD] build and release in CI
This will produce the following behaviour: When a commit with a title like "Bump to version x.y.z" is committed to main branch (either by merging a merge request or by pushing it directly to the main branch), a build of the project is triggered and the result is pushed on PyPI. Also a release on the github project is created with the version of the program as title and the content of the commit message as description. This will help deploying release of oow. It will also warn followers that a new version is released by a notification if they choose to. PYPI_USER and PYPI_TOKEN are value set on the gitlab settings of the project and can only be viewed by maintainers.
This commit is contained in:
parent
badba4bd31
commit
59025a14e0
|
|
@ -1,6 +1,8 @@
|
|||
stages:
|
||||
- lint
|
||||
- test
|
||||
- build
|
||||
- release
|
||||
|
||||
pre-commit:
|
||||
stage: lint
|
||||
|
|
@ -41,3 +43,45 @@ pytest:
|
|||
tests/cli_08_estimate_workload_test.py
|
||||
tests/cli_20_install_from_csv_test.py
|
||||
tests/cli_21_generate_module_analysis_test.py
|
||||
|
||||
build:
|
||||
stage: build
|
||||
image: python:latest
|
||||
rules:
|
||||
# Do not run this job when a tag is created manually
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: never
|
||||
# Run this job when commits are pushed or merged to the default branch
|
||||
# and the commit message contains "Bump to version"
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^Bump to version.+/
|
||||
script:
|
||||
- pip install poetry
|
||||
- poetry --version
|
||||
- poetry build
|
||||
- poetry publish --username $PYPI_USER --password $PYPI_TOKEN
|
||||
- echo "VERSION=$(poetry version --short)" >> variables.env
|
||||
artifacts:
|
||||
reports:
|
||||
# Use artifacts:reports:dotenv to expose the variables to other jobs
|
||||
dotenv: variables.env
|
||||
|
||||
release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
needs:
|
||||
- job: build
|
||||
artifacts: true
|
||||
rules:
|
||||
# Do not run this job when a tag is created manually
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: never
|
||||
# Run this job when commits are pushed or merged to the default branch
|
||||
# and the commit message contains "Bump to version"
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^Bump to version.+/
|
||||
script:
|
||||
- echo "running release_job for $VERSION"
|
||||
release:
|
||||
name: "$VERSION"
|
||||
description: "$CI_COMMIT_DESCRIPTION"
|
||||
tag_name: "$VERSION"
|
||||
ref: "$CI_COMMIT_SHA"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user