diff --git a/.github/workflows/CompletePipeline.yml b/.github/workflows/CompletePipeline.yml index de40f62a..d0fca361 100644 --- a/.github/workflows/CompletePipeline.yml +++ b/.github/workflows/CompletePipeline.yml @@ -143,6 +143,11 @@ on: required: false default: 'true' type: string + pypi_dry_run: + description: 'Validate the packages with twine, but do not upload them to PyPI.' + required: false + default: 'false' + type: string cleanup: description: 'Cleanup artifacts afterwards.' required: false @@ -537,6 +542,7 @@ jobs: python_version: ${{ needs.UnitTestingParams.outputs.python_version }} requirements: '-r dist/requirements.txt' artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} + dry_run: ${{ inputs.pypi_dry_run }} cleanup: ${{ inputs.cleanup }} secrets: PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/PublishOnPyPI.yml b/.github/workflows/PublishOnPyPI.yml index 0411235c..1628f106 100644 --- a/.github/workflows/PublishOnPyPI.yml +++ b/.github/workflows/PublishOnPyPI.yml @@ -44,6 +44,11 @@ on: description: 'Name of the package artifact.' required: true type: string + dry_run: + description: 'Validate the packages with twine, but do not upload them to PyPI.' + required: false + default: 'false' + type: string cleanup: description: 'Cleanup artifacts afterwards.' required: false @@ -74,13 +79,19 @@ jobs: - name: โš™ Install dependencies for packaging and release run: python -m pip install --disable-pip-version-check ${{ inputs.requirements }} + - name: ๐Ÿ”Ž Check Python packages instead of publishing them + if: inputs.dry_run == 'true' + run: twine check dist/*.whl dist/*.tar.gz + - name: โคด Publish Python wheel package to PyPI + if: inputs.dry_run != 'true' env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: twine upload dist/*.whl - name: โคด Publish Python source package to PyPI + if: inputs.dry_run != 'true' env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} diff --git a/doc/JobTemplate/AllInOne/CompletePipeline.rst b/doc/JobTemplate/AllInOne/CompletePipeline.rst index d5e946dd..90d846de 100644 --- a/doc/JobTemplate/AllInOne/CompletePipeline.rst +++ b/doc/JobTemplate/AllInOne/CompletePipeline.rst @@ -471,6 +471,8 @@ Parameter Summary +--------------------------------------------------------------------+----------+--------+----------------------------------------------------------------------------+ | :ref:`JOBTMPL/CompletePipeline/Input/dorny` | no | string | ``'false'`` | +--------------------------------------------------------------------+----------+--------+----------------------------------------------------------------------------+ +| :ref:`JOBTMPL/CompletePipeline/Input/pypi_dry_run` | no | string | ``'false'`` | ++--------------------------------------------------------------------+----------+--------+----------------------------------------------------------------------------+ | :ref:`JOBTMPL/CompletePipeline/Input/cleanup` | no | string | ``'true'`` | +--------------------------------------------------------------------+----------+--------+----------------------------------------------------------------------------+ @@ -932,6 +934,23 @@ auto_tag ``'false'`` - never tag automatically. +.. _JOBTMPL/CompletePipeline/Input/pypi_dry_run: + +pypi_dry_run +============ + +:Type: string +:Required: no +:Default Value: ``'false'`` +:Possible Values: ``'true'`` / ``'false'`` +:Description: Validate the built packages with ``twine check`` instead of uploading them to :term:`PyPI`. + Forwarded to :ref:`JOBTMPL/PublishOnPyPI/Input/dry_run`. |br| + Intended for a pipeline that builds a package which is never published - a fixture used to + exercise the job templates, or a fork that must not push to the upstream project's PyPI name. |br| + ``'true'`` - check the packages and publish nothing. |br| + ``'false'`` - publish the packages. + + .. _JOBTMPL/CompletePipeline/Input/cleanup: cleanup diff --git a/doc/JobTemplate/Package/PublishOnPyPI.rst b/doc/JobTemplate/Package/PublishOnPyPI.rst index af026860..a7ed8bdd 100644 --- a/doc/JobTemplate/Package/PublishOnPyPI.rst +++ b/doc/JobTemplate/Package/PublishOnPyPI.rst @@ -22,6 +22,9 @@ Publish a wheel (``*.whl``) packages and/or source (``*.tar.gz``) package to :te (:ref:`JOBTMPL/PublishOnPyPI/Input/requirements`), which must provide :term:`twine`. 3. Publish the wheel package(s) (:file:`*.whl`). 4. Publish the source package(s) (:file:`*.tar.gz`). + + Steps 3 and 4 are replaced by a ``twine check`` of both package kinds if + :ref:`JOBTMPL/PublishOnPyPI/Input/dry_run` is enabled. 5. Delete the artifact (:ref:`JOBTMPL/PublishOnPyPI/Input/cleanup`). .. topic:: Preconditions @@ -125,6 +128,8 @@ Parameter Summary +---------------------------------------------------------+----------+--------+-------------------+ | :ref:`JOBTMPL/PublishOnPyPI/Input/artifact` | yes | string | โ€” โ€” โ€” โ€” | +---------------------------------------------------------+----------+--------+-------------------+ +| :ref:`JOBTMPL/PublishOnPyPI/Input/dry_run` | no | string | ``'false'`` | ++---------------------------------------------------------+----------+--------+-------------------+ | :ref:`JOBTMPL/PublishOnPyPI/Input/cleanup` | no | string | ``'true'`` | +---------------------------------------------------------+----------+--------+-------------------+ @@ -182,6 +187,22 @@ artifact :Description: Name of the artifact containing the packaged Python package(s). +.. _JOBTMPL/PublishOnPyPI/Input/dry_run: + +dry_run +======= + +:Type: string +:Required: no +:Default Value: ``'false'`` +:Possible Values: ``'true'`` / ``'false'`` +:Description: Validate the packages with ``twine check`` instead of uploading them to :term:`PyPI`. |br| + Everything up to the upload still runs, so the artifact download, the Python setup and the package + metadata are exercised - only the two ``twine upload`` calls are skipped. |br| + ``'true'`` - check the packages and publish nothing. |br| + ``'false'`` - publish the packages. + + .. _JOBTMPL/PublishOnPyPI/Input/cleanup: cleanup