Commit 28d90cca authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'add-package-stage' into 'master'

refactor: move package building to dedicated stage

See merge request to-be-continuous/python!20
parents 3f7db4ec 945fc8a8
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -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:

+12 −0
Original line number Diff line number Diff line
@@ -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",
+20 −1
Original line number Diff line number Diff line
@@ -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: