Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: add automatic publication to pypi.org and test.pypi.org #46

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

hnez
Copy link
Member

@hnez hnez commented Apr 23, 2024

Publishing software manually is a (somewhat) error-prone and (somewhat) tedious process, hence why other projects have already automated this process.

Let's join these other projects and also automate our publication process!

The setup process is surprisingly straight forward and involves setting up trusted publishing on both pypi.org, as well as test.pypi.org for the lxa-iobus project:

pypi-auto

And setting a GitHub Action Variable that enables publication (so that the job does not run and fail for forked repositories by default):

github-variable

TODO before merging:

Both of these PRs should be merged before this one.

@hnez
Copy link
Member Author

hnez commented Apr 23, 2024

I should mention that this PR is heavily inspired by @jluebbe's work over at pdudaemon/pdudaemon#155.
I did however tweak a few aspects:

  • Use an if-block at the job level to prevent the job from even starting when the conditions are not met.
  • Use a GitHub action variable to prevent the job from running for forks.
  • Always publish to test.pypi.org, even for tags.

@hnez hnez force-pushed the auto-pypi branch 2 times, most recently from f311274 to ce7591e Compare April 24, 2024 12:59
We want to reduce the potential for human error in our publication process
and also streamline the process for everyone with the permission to create
tags in the repository.

The CI job runs for new commits pushed to the master branch and newly
pushed tags, as long as the PUBLISH_PYPI GitHub Action variable is set
to "true".
This is to prevent CI runs on forked repository from failing because they
are not allowed to publish on pypi.org and test.pypi.org.
A fork that wants to use the publish logic just has to set the
PUBLISH_PYPI variable for their repository.

The job does not check out the git repository (hence why it does not use
the existing publication logic in the Makefile) and instead downloads
the artifacts generated by the build job.

All builds are uploaded to test.pypi.org (so they can be tested via pip
install) and tagged releases are uploaded to pypi.org as well.

Also remove the upload helpers from the Makefile to make it clear that
they are replaced by the automated process.

Signed-off-by: Leonard Göhrs <[email protected]>
@SmithChart SmithChart merged commit 4bc94a6 into linux-automation:master Apr 24, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants