supports github releases
Project description
setuptools-github
Quick start
setuptools-github helps to implement a simple project life cycle aimed at delivering packages into PyPI from a hosted project at Github. We assume this layout:
project-name/
├── setup.py
├── pyproject.toml
├── .github
│ └── workflows <- workflow files for
│ ├── beta.yml * beta/N.M.O branches
│ ├── master.yml * master branch
│ └── tags.yml * release/N.M.O tags
├── src
│ └── project_name <- project name
│ └── __init__.py <- version_file
└── tests <- tests (pytest)
├── conftest.py
└── requirements.txt <- requirement file for tests
NOTE for a pyproject.toml / hatch enabled version of this, please use hatch-ci plugin
install the package
pip install setuptools-github
or
conda install -c conda-forge setuptools-github
put the initial version info in the version_file
Create a new src/project_name/__init__.py
file to store the package information:
__version__ = "N.M.O" # replace N, M and O with numerical values (eg. 0.0.0)
__hash__ = "" # leave this empty
Fix the setup.py file
from setuptools_github import tools
setup(
name="project-name",
version=tools.update_version(version_file, os.getenv("GITHUB_DUMP")),
...
NOTE: there's an advanced function
tools.process
that can update and process files like the readmes (see an example in setup.py)
Add the github workflow files
NOTE: Most likely you might need to change:
- the
tests/requirements.txt
file- the envs variables at the beging of
master.yml
andbeta.yml
Add secrets
In order to publish to codecov the coveragen info and to PyPI the wheels, you need to set the github secrets under:
https://github.com/username/project-name/settings/secrets/actions
These are the needed secrets for the PyPI index and codecov services:
- TWINE_PASSWORD
- TWINE_USERNAME
- CODECOV_TOKEN
THAT IS ALL! Now when commit to the master branch, this will trigger the github action to run tests and quality checks on the code
Working with branches
Working with the master branch
Every time there's a commit on the master branch, this will trigger the workflow under ./github/workflows/master.yml:
- Runs mypy on src/
- Runs ruff on src/
- Run all tests under tests/
On completion static and dynamic tests are supported.
Setup the beta/N.M.O branch
In order to prepare for a release a new beta/N.M.O branch should be created:
python -m setuptools_github.script make-beta src/project_name/__init__.py
or
setuptools-github make-beta src/project_name/__init__.py
Every commit on beta/N.M.O branch if Secrets have been set properly:
- Runs mypy on src/
- Runs ruff on src/
- Run all tests under tests/
- Run coverage on tests/
- Send the coverage result into coverage
- Create a new wheel package under dist/
- (on success) Send the new wheels package-N.M.O.bX to PyPI
NOTE: the name project-N.M.O.bX contains the X: this is an incrementing counter set during build. This means project-N.M.O.bX < project-N.M.O allowing the correct package ordering.
Release the project N.M.O
To release an official package for project-N.M.O from the beta/N.M.O branch:
python -m setuptools_github.script micro src/project_name/__init__.py
or
setuptools-github make-beta micro src/project_name/__init__.py
This will tag the HEAD on beta/N.M.O branch with the release/N.M.O tag and increment the version_file with the next version N.M.O+1 (using micro).
Once done, you'll need to push it the tag.
git push release/N.M.O
This will:
- trigger a CI build that will create the project-name-N.M.O
- Create a new wheel package under dist/
- (on success) Send the new wheels project-N.M.O to PyPI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for setuptools-github-0.3.7b92.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21823c8838f655cc6c49c6623eac21e44b706ec6048d21ece6652d8486623f13 |
|
MD5 | 35f282ec2c846de1483df4d3e5e1748c |
|
BLAKE2b-256 | 5c63e265d68bee6abd7b24418ce50c6acd78b0e0293aeecdd5bdb349c61f097c |
Hashes for setuptools_github-0.3.7b92-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f53c3c72077b5a9634a9166a46b584f8e0d3daeb7e5175e2d9d8dfcab4dda026 |
|
MD5 | 6d5177b2e3b81f917e81dc978f061cc9 |
|
BLAKE2b-256 | 4e72c90db8215ad636a086be3beaf51ff2621d42a0028597fe50d7b12d1f644e |