From 5c812e2a67434d44f87778f5dc5b8c3517de0e14 Mon Sep 17 00:00:00 2001 From: Alexandre Muller Date: Mon, 8 Jan 2024 09:51:19 +0100 Subject: [PATCH] github: add workflow to publish on PyPI --- .github/workflows/publish-to-pipy.yml | 27 ++++++++++ RELEASE.rst | 77 +++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 .github/workflows/publish-to-pipy.yml create mode 100644 RELEASE.rst diff --git a/.github/workflows/publish-to-pipy.yml b/.github/workflows/publish-to-pipy.yml new file mode 100644 index 0000000..f99640b --- /dev/null +++ b/.github/workflows/publish-to-pipy.yml @@ -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 diff --git a/RELEASE.rst b/RELEASE.rst new file mode 100644 index 0000000..dc230e1 --- /dev/null +++ b/RELEASE.rst @@ -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/