Merge branch 'ci-build-and-release' into 'main'

[ADD] build and release in CI

See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!41
This commit is contained in:
LE GAL SYLVAIN 2023-07-11 21:11:18 +00:00
commit 0764b811d5

View File

@ -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"