-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github: add workflow to publish on PyPI
- Loading branch information
Showing
2 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
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: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 had current date to the changelog. | ||
|
||
If you agree with the prefilled version, you can run:: | ||
|
||
$ prerelease --no-input | ||
|
||
Otherwise, run the command without option. Zest will ask you a new version number and | ||
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`` | ||
|
||
Then, Zest asks you if you want to check out the tag for pypi server upload. Answer | ||
``n`` as the upload will be done by Github CI. | ||
|
||
Postrelease | ||
----------- | ||
|
||
Finally, it's time to prepare the project back to development and push changes to the server. | ||
|
||
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, Zest asks you to valid commit changes. Press ``Y``. | ||
|
||
Finally, Zest asks you if you want to push your changes on the server. Press ``Y``. | ||
|
||
Upload of the new release o 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 trigered. The pipeline is composed of 3 main | ||
steps: | ||
|
||
* Setup Python and install build dependency | ||
* Build the new project release | ||
* Upload artefacts 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/ |