diff --git a/README.md b/README.md index edb7410f6bf451fc60df9401bf27bda6866def35..6591f4631059285fe25e69ff6f61af2deb503af0 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,18 @@ It is bound to the `test` stage, and uses the following variables: This job outputs a **textual report** in the console, and in case of failure also exports a JSON report in the `reports/` directory _(relative to project root dir)_. +### Package jobs + +#### `py-package` job + +This job is performs a packaging of your Python code. + +It is bound to the `package-build` stage, applies only on git tags and uses the following variables: + +| Name | description | default value | +| --------------- | ---------------------------------------------------- | ------------- | +| `PYTHON_FORCE_PACKAGE` | Force the packaging even if not on tag related event | _none_ | + ### Publish jobs #### `py-release` job @@ -251,7 +263,7 @@ It is bound to the `publish` stage, applies only on master branch and uses the f #### `py-publish` job -This job is **disabled by default** and performs a packaging and publication of your Python code. +This job is **disabled by default** and performs a publication of your Python code. It is bound to the `publish` stage, applies only on git tags and uses the following variables: diff --git a/kicker.json b/kicker.json index 33ebec6ba992ddefcbb13c946755a35c529930be..ae86c1ea1b0b74803e7417d2323ef0a5b6362ebe 100644 --- a/kicker.json +++ b/kicker.json @@ -147,6 +147,18 @@ } ] }, + { + "id": "package", + "name": "package", + "description": "Packaging of your Python code", + "variables": [ + { + "name": "PYTHON_FORCE_PACKAGE", + "description": "Force the packaging even if not on tag related event", + "type": "boolean" + } + ] + }, { "id": "publish", "name": "Publish", diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml index 13b523e672ec725dc7ca988841b671e012b47039..15347f614c2f2acbd876f35c4320d8fa7da0c30d 100644 --- a/templates/gitlab-ci-python.yml +++ b/templates/gitlab-ci-python.yml @@ -337,6 +337,7 @@ variables: stages: - build - test + - package-build - publish ############################################################################################### @@ -560,6 +561,25 @@ py-safety: allow_failure: true +############################################################################################### +# pakage stage # +############################################################################################### + +# (on tag creation): create packages as artifacts +py-package: + extends: .python-base + stage: package-build + script: + - python setup.py sdist bdist_wheel + artifacts: + paths: + - $PYTHON_PROJECT_DIR/dist/*.tar.gz + - $PYTHON_PROJECT_DIR/dist/*.whl + rules: + # on tags + - if: '$CI_COMMIT_TAG' + - if: '$PYTHON_FORCE_PACKAGE == "true"' + ############################################################################################### # publish stage # ############################################################################################### @@ -573,7 +593,6 @@ py-publish: - assert_defined "$TWINE_PASSWORD" 'Missing required env $TWINE_PASSWORD' - pip install -U twine setuptools - pip list - - python setup.py sdist bdist_wheel - twine upload --verbose dist/*.tar.gz - twine upload --verbose dist/*.whl rules: