Skip to content

Commit

Permalink
github: add workflow to publish on PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
sandre35 committed Jan 15, 2024
1 parent eafb50f commit 5c812e2
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/publish-to-pipy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Python distribution to PyPI

on: push

jobs:
publish-to-pypi:
name: Publish Python distribution to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/xlsx_streaming
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install pypa/build
run: pip install build
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
77 changes: 77 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Releasing a new version
=======================

Installation
------------

Install Zest tool that automates process of releasing a new version of a Python package::

$ pip install zest.releaser

Clean master branch
-------------------

Make sure you are working on a safe master branch::

$ git checkout master
$ git reset origin/master --hard
$ make clean

Prerelease
----------

Once you are ready to release a new version, let's begin with the first command
``prerelease``. This command aims to change the setup.cfg's version and add the
current date to the changelog.

If you agree with the prefilled version, you can directly run::

$ prerelease --no-input

Otherwise, run the command without option. Zest will ask you a version number. Then
valid commit changes.

Release
-------

Then, let's focus on the ``release`` command. This command focuses on creating a tag and
uploading the new package to PyPI.

The command line asks you to valid the tag command. Press ``Y``

The next question is about uploading the package to a custom repository. Press ``n``.

Postrelease
-----------

Finally, it's time to prepare the project back to development and push commits remotely.

Run the command::

$ postrelease --feature

The first question is about the next development version. By default, the minor number
will be increased. If you want to enter another version, please do not add ``.dev0`` as
it is automatically added by Zest.

Then, valid commit changes. Press ``Y``.

Finally, you need to push local commits on the server. Press ``Y``.

Upload of the new release to PyPI
--------------------------------

This section is purely informative, everything is done automatically. Integration to
PyPI is done through the use of Github CI/CD. Declaration of the pipeline is done in
``.github/workflows/publish-to-pipy.yml``

On tag push, the job `publish-to-pypi` is triggered. The pipeline is composed of 3 main
steps:

* Setup Python and install build dependency
* Build the new project release
* Upload artifacts to PyPI

Setup of this pipeline is inspired from this `guide`_.

.. _guide: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

0 comments on commit 5c812e2

Please sign in to comment.