Skip to main content

Publish python package to PyPI and Github

Project description

Codacy Quality Badge Codacy Coverage Badge

publish is a tool to package and release a python project. It will create a changelog and upload artifacts to Github and PyPI.

It is created for and by the FIAAS project, and used for most of our projects.

Usage

In order to use publish, you must first install it:

pip install publish

Under the covers, publish uses github-release and twine to do most of the work, and those tools require credentials for Github and PyPI to be available in environment variables:

export GITHUB_TOKEN=gh-token
export TWINE_USERNAME=pypi-user
export TWINE_PASSWORD=pypi-pass

In order to know where to upload the artifacts, you must specify an organization, and a repository:

publish fiaas k8s

Before uploading anything, publish will verify that the current checkout is suitable to be released, and checks the following items:

  • Are all files either ignored or in version control?

  • Is every change committed?

  • Is the currently checked out code tagged with an annotated tag?

  • Does that tag use the convention v<major>.<minor>.<bugfix>?

If the answer to all of these is yes, the name of the tag is used as the version to release. A changelog is generated from the git log, source tarballs and wheels are built, the release is created in Github and PyPI, and the files are uploaded.

When uploading a release to Github, the changelog is attached to the release automatically.

In order for the changelog to be attached to the release on PyPI, it needs to be included in the long description generated by setup.py. To help with this, the changelog is written to a file, and the name of the file is available in an environment variable called CHANGELOG_FILE. Append the contents of this file to your long description, and it will be included in the description on PyPI.

Releasing

To make a new release of this project, there are a couple steps to follow. Ideally, we want to release from master, as often as possible. Version numbers should adhere to SemVer. When you have a passing build that you want to make a release from, do the following steps:

  • Create an annotated tag for the commit in question, naming it v<major>.<minor>.<bugfix>. For instance:

    $ git tag -a v0.0.2 a1b2c3d4
  • Push the new tag to github:

    $ git push origin v0.0.2
  • A new release with the version you selected as a tag should now be built and uploaded to PyPI and Github

Changes since last version

  • 8272c77: Upgrade twine to 5.1.1

  • 1c90074: Use ubuntu2004 CI image

  • a866d45: Document how to make a release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

publish-0.3.6.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

publish-0.3.6-py2.py3-none-any.whl (11.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file publish-0.3.6.tar.gz.

File metadata

  • Download URL: publish-0.3.6.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for publish-0.3.6.tar.gz
Algorithm Hash digest
SHA256 a1194e97338f0037a6e1cc5d2dbaf6d355ad8fee2d11dd089a230475df6e6964
MD5 a8906a1d6b42e31b26af2ebbf1b26149
BLAKE2b-256 fc9b042300b82381afe742ac4b220e5b6a0157118e928ee96216e815a2612b3a

See more details on using hashes here.

File details

Details for the file publish-0.3.6-py2.py3-none-any.whl.

File metadata

  • Download URL: publish-0.3.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for publish-0.3.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b8a6f95cd4b451f478613d05ebaa914a2909338ddafd135bca9ba359789a9fd6
MD5 0dd96951ddc8f92a7c0acf393c3753d9
BLAKE2b-256 599a74e6c741a4cbd811ca467d3f260fe2a759587a593e51d4da588e9c8e4f1c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page