diff --git a/.github/workflows/Package.yml b/.github/workflows/Package.yml index e23de40..5dec248 100644 --- a/.github/workflows/Package.yml +++ b/.github/workflows/Package.yml @@ -78,15 +78,15 @@ jobs: # build (not isolated) - - name: ๐Ÿ”ง [build] Install dependencies for packaging and release + - name: ๐Ÿ”ง [build - no-isolation] Install dependencies for packaging and release if: inputs.requirements == 'no-isolation' run: python -m pip install --disable-pip-version-check build - - name: ๐Ÿ”จ [build] Build Python package (source distribution) + - name: ๐Ÿ”จ [build - no-isolation] Build Python package (source distribution) if: inputs.requirements == 'no-isolation' run: python -m build --no-isolation --sdist - - name: ๐Ÿ”จ [build] Build Python package (binary distribution - wheel) + - name: ๐Ÿ”จ [build - no-isolation] Build Python package (binary distribution - wheel) if: inputs.requirements == 'no-isolation' run: python -m build --no-isolation --wheel diff --git a/.github/workflows/PublishOnPyPI.yml b/.github/workflows/PublishOnPyPI.yml index 49e073c..e130ff6 100644 --- a/.github/workflows/PublishOnPyPI.yml +++ b/.github/workflows/PublishOnPyPI.yml @@ -69,18 +69,18 @@ jobs: - name: โš™ Install dependencies for packaging and release run: python -m pip install --disable-pip-version-check ${{ inputs.requirements }} - - name: โคด Release Python source package to PyPI - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: twine upload dist/*.tar.gz - - - name: โคด Release Python wheel package to PyPI + - name: โคด Publish Python wheel package to PyPI env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: twine upload dist/*.whl + - name: โคด Publish Python source package to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: twine upload dist/*.tar.gz + - name: ๐Ÿ—‘๏ธ Delete packaging Artifacts uses: geekyeggo/delete-artifact@v5 with: diff --git a/doc/JobTemplate/Package/Package.rst b/doc/JobTemplate/Package/Package.rst index 379f12a..c233490 100644 --- a/doc/JobTemplate/Package/Package.rst +++ b/doc/JobTemplate/Package/Package.rst @@ -162,7 +162,7 @@ requirements Either a requirements file can be referenced using ``'-r path/to/requirements.txt'``, or a list of packages can be specified using a space separated list like ``'build wheel'``. :Behavior: If the value is an empty string, :pypi:`build` is used for packaging. |br| - if the value is ``no-isolation``, :ypy:`build` is used in *no-isolation* mode for packaging. |br| + if the value is ``no-isolation``, :pypi:`build` is used in *no-isolation* mode for packaging. |br| otherwise, a list of requirements is assumed and :pypi:`setuptools` is used for packaging. :Description: Python dependencies to be installed through *pip*. @@ -175,7 +175,7 @@ artifact :Type: string :Required: yes :Possible Values: Any valid artifact name. -:Description: Name of the artifact containing the unittest report summary in XML format. +:Description: Name of the artifact containing the packaged Python code. .. _JOBTMPL/Package/Secrets: diff --git a/doc/JobTemplate/Package/PublishOnPyPI.rst b/doc/JobTemplate/Package/PublishOnPyPI.rst index c0032cb..3843afc 100644 --- a/doc/JobTemplate/Package/PublishOnPyPI.rst +++ b/doc/JobTemplate/Package/PublishOnPyPI.rst @@ -3,29 +3,46 @@ PublishOnPyPI ############# -Publish a source (``*.tar.gz``) package and/or wheel (``*.whl``) packages to `PyPI `__. +Publish a wheel (``*.whl``) packages and/or source (``*.tar.gz``) package to `PyPI `__. -**Behavior:** +.. topic:: Features -1. Download package artifact -2. Publish source package(s) (``*.tar.gz``) -3. Publish wheel package(s) (``*.whl``) -4. Delete the artifact + * Publish a Python package to `PyPI `__. -**Preconditions:** +.. topic:: Behavior: -A PyPI account was created and the package name is either not occupied or the user has access rights for that package. + 1. Download package artifact + 2. Publish source package(s) (``*.tar.gz``) + 3. Publish wheel package(s) (``*.whl``) + 4. Delete the artifact -**Requirements:** +.. topic:: Preconditions: -Setup a secret (e.g. ``PYPI_TOKEN``) in GitHub to handover the PyPI token to the job. + 1. A PyPI account was created and the package name is either not occupied or the user has access rights for that + package. + 2. An access token was generated at PyPI, which can be used for uploading packages. + 3. A secret (e.g. ``PYPI_TOKEN``) was setup in GitHub Actions to handover the PyPI token to the pipeline. -**Dependencies:** +.. topic:: Job Execution -* :gh:`actions/download-artifact` -* :gh:`actions/setup-python` -* :gh:`geekyeggo/delete-artifact` + .. image:: ../../_static/pyTooling-Actions-PublishOnPyPI.png + :width: 500px +.. topic:: Dependencies + + * :gh:`pyTooling/download-artifact` + + * :gh:`actions/download-artifact` + * :gh:`actions/setup-python` + * :gh:`geekyeggo/delete-artifact` + + * pip + + * :pypi:`wheel` + * :pypi:`twine` + + +.. _JOBTMPL/PublishOnPyPI/Instantiation: Instantiation ************* @@ -78,62 +95,136 @@ by that job. Finally, the list of requirements is overwritten to load a list of secrets: PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} +.. seealso:: -Parameters -********** + :ref:`JOBTMPL/Package` + + +.. _JOBTMPL/PublishOnPyPI/Parameters: + +Parameter Summary +***************** + +.. rubric:: Goto :ref:`input parameters ` + ++---------------------------------------------------------------------+----------+----------+-------------------------------------------------------------------+ +| Parameter Name | Required | Type | Default | ++=====================================================================+==========+==========+===================================================================+ +| :ref:`JOBTMPL/PublishOnPyPI/Input/ubuntu_image_version` | no | string | ``'24.04'`` | ++---------------------------------------------------------------------+----------+----------+-------------------------------------------------------------------+ +| :ref:`JOBTMPL/PublishOnPyPI/Input/python_version` | no | string | ``'3.13'`` | ++---------------------------------------------------------------------+----------+----------+-------------------------------------------------------------------+ +| :ref:`JOBTMPL/PublishOnPyPI/Input/requirements` | no | string | ``'wheel twine'`` | ++---------------------------------------------------------------------+----------+----------+-------------------------------------------------------------------+ +| :ref:`JOBTMPL/PublishOnPyPI/Input/artifact` | yes | string | โ€” โ€” โ€” โ€” | ++---------------------------------------------------------------------+----------+----------+-------------------------------------------------------------------+ + +.. rubric:: Goto :ref:`secrets ` + ++-----------------------------------------------------------+----------+----------+--------------+ +| Token Name | Required | Type | Default | ++===========================================================+==========+==========+==============+ +| :ref:`JOBTMPL/PublishOnPyPI/Secret/PYPI_TOKEN` | no | string | โ€” โ€” โ€” โ€” | ++-----------------------------------------------------------+----------+----------+--------------+ + +.. rubric:: Goto :ref:`output parameters ` + +This job template has no output parameters. + + +.. _JOBTMPL/PublishOnPyPI/Inputs: + +Input Parameters +**************** + +.. _JOBTMPL/PublishOnPyPI/Input/ubuntu_image_version: + +ubuntu_image_version +==================== + +:Type: string +:Required: no +:Default Value: ``'24.04'`` +:Possible Values: See `actions/runner-images - Available Images `__ + for available Ubuntu image versions. +:Description: Version of the Ubuntu image used to run this job. + + .. note:: + + Unfortunately, GitHub Actions has only a `limited set of functions `__, + thus, the usual Ubuntu image name like ``'ubuntu-24.04'`` can't be split into image name and image + version. + + +.. _JOBTMPL/PublishOnPyPI/Input/python_version: python_version ============== -+----------------+----------+----------+----------+ -| Parameter Name | Required | Type | Default | -+================+==========+==========+==========+ -| python_version | optional | string | ``3.11`` | -+----------------+----------+----------+----------+ +:Type: string +:Required: no +:Default Value: ``'3.13'`` +:Possible Values: Any valid Python version conforming to the pattern ``.`` or ``pypy-.``. |br| + See `actions/python-versions - available Python versions `__ + and `actions/setup-python - configurable Python versions `__. +:Description: Python version used as default for other jobs requiring a single Python version. |br| + In case :ref:`JOBTMPL/Parameters/Input/python_version_list` is an empty string, this version is used + to populate the version list. -Python version used for uploading the package contents via `twine` to PyPI. +.. _JOBTMPL/PublishOnPyPI/Input/requirements: requirements ============ -+----------------+----------+----------+-----------------+ -| Parameter Name | Required | Type | Default | -+================+==========+==========+=================+ -| requirements | optional | string | ``wheel twine`` | -+----------------+----------+----------+-----------------+ +:Type: string +:Required: no +:Default Value: ``''`` +:Possible Values: Any valid list of parameters for ``pip install``. |br| + Either a requirements file can be referenced using ``'-r path/to/requirements.txt'``, or a list of + packages can be specified using a space separated list like ``'wheel twine'``. +:Description: Python dependencies to be installed through *pip*. -List of requirements to be installed for uploading the package contents to PyPI. +.. _JOBTMPL/PublishOnPyPI/Input/artifact: artifact ======== -+----------------+----------+----------+--------------+ -| Parameter Name | Required | Type | Default | -+================+==========+==========+==============+ -| artifact | yes | string | โ€” โ€” โ€” โ€” | -+----------------+----------+----------+--------------+ +:Type: string +:Required: yes +:Possible Values: Any valid artifact name. +:Description: Name of the artifact containing the packaged Python package(s). -Name of the artifact containing the package(s). +.. _JOBTMPL/PublishOnPyPI/Secrets: Secrets ******* + +.. _JOBTMPL/PublishOnPyPI/Secret/PYPI_TOKEN: + PYPI_TOKEN ========== -+----------------+----------+----------+--------------+ -| Secret Name | Required | Type | Default | -+================+==========+==========+==============+ -| PYPI_TOKEN | yes | string | โ€” โ€” โ€” โ€” | -+----------------+----------+----------+--------------+ - -The token to access the package at PyPI for uploading new data. +:Type: string +:Required: no +:Default Value: โ€” โ€” โ€” โ€” +:Description: The token to publish and upload packages on `PyPI `__. -Results +.. _JOBTMPL/PublishOnPyPI/Outputs: + +Outputs ******* This job template has no output parameters. + + +.. _JOBTMPL/PublishOnPyPI/Optimizations: + +Optimizations +************* + +This template offers no optimizations (reduced job runtime). diff --git a/doc/_static/pyTooling-Actions-PublishOnPyPI.png b/doc/_static/pyTooling-Actions-PublishOnPyPI.png new file mode 100644 index 0000000..d82f03b Binary files /dev/null and b/doc/_static/pyTooling-Actions-PublishOnPyPI.png differ