This repository uses UV for building and publishing the package to PyPI. The GitHub Actions workflow defined in .github/workflows/main.yaml automates the following steps:
-
Linting and Type Checking: The workflow runs linting, formatting, type-checking, and unit tests on every commit and pull request.
-
Building and Publishing: When a new Git tag is pushed, the workflow:
- Checks out the source code.
- Sets up Python and installs UV.
- Syncs dependencies.
- Builds the package using
uv build. - Publishes the package to PyPI using
uv publish.
-
Update the Version in
pyproject.toml: In the[project]section of yourpyproject.toml, update theversionfield:[project] name = "your_package_name" version = "X.Y.Z" # Update this to your new version description = "Your package description." # ... other metadata ...
-
Commit Your Changes: Commit the updated
pyproject.toml(or any other relevant files) to your repository.git add pyproject.toml git commit -m "Bump version to X.Y.Z" -
Tag the Commit: Create a git tag following your versioning convention (e.g.,
vX.Y.Z):git tag vX.Y.Z
Alternatively, you can also create a tag using the GitHub web interface to draft a new release, which will automatically tag the commit.
-
Push the Changes and the Tag: Push your commit and tags to the main branch:
git push origin main --tags
-
Automatic Build and Publish: Once the tag is pushed, GitHub Actions will trigger the
build-and-publishjob:- Build: The job runs
uv buildto create the package distributions. - Publish: The job then runs
uv publish --token $UV_PUBLISH_TOKENto publish the package to PyPI. Make sure that thePYPI_API_TOKENsecret is set in your repository configuration.
- Build: The job runs
-
Verify the Release:
- Check the workflow run in GitHub Actions for any errors.
- Confirm that the new version is available on PyPI.
- Version Management: The version published to PyPI is read from the
pyproject.tomlfile. It is your responsibility to update it for each release. - Secrets: Ensure that the secret
PYPI_API_TOKENis defined in your repository's settings. This token should have the necessary permissions to publish to PyPI. - Workflow Dependencies: The publishing step depends on successful completion of linting, type-checking, and unit tests.
Happy releasing!