Skip to content

Commit 29ec6d5

Browse files
committed
+ badges
1 parent d1af116 commit 29ec6d5

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Template Repo
22

3-
<a href="https://github.com/jorgemarpa/repo-template/actions/workflows/pytest.yml"><img src="https://github.com/ssdatalab/psfmachine/workflows/pytest/badge.svg" alt="Test status"/></a>
4-
<!-- <a href="https://pypi.python.org/pypi/psfmachine"><img src="https://img.shields.io/pypi/v/psfmachine" alt="pypi status"></a> -->
5-
<!-- <a href="https://zenodo.org/record/4784073"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.4784073.svg"></a> -->
3+
[![PyPI](https://img.shields.io/tpypi/v/repo-template.svg)](https://test.pypi.org/project/repo-template)
4+
[![pytest](https://github.com/jorgemarpa/repo-template/actions/workflows/pytest.yml/badge.svg)](https://github.com/jorgemarpa/repo-template/actions/workflows/pytest.yml/) [![mypy](https://github.com/jorgemarpa/repo-template/actions/workflows/mypy.yml/badge.svg)](https://github.com/jorgemarpa/repo-template/actions/workflows/mypy.yml) [![ruff](https://github.com/jorgemarpa/repo-template/actions/workflows/ruff.yml/badge.svg)](https://github.com/jorgemarpa/repo-template/actions/workflows/ruff.yml)[![Docs](https://github.com/jorgemarpa/repo-template/actions/workflows/deploy-mkdocs.yml/badge.svg)](https://github.com/jorgemarpa/repo-template/actions/workflows/deploy-mkdocs.yml)
65

76
This is a template repository ready to develop code. It uses poetry to manage dependencies, python environmnet, and packagaing. Flake8 and Black to format code. Mkdocs to create documentation from docstrings. And adds GitHub actions to automitize tasks.
87

@@ -98,7 +97,37 @@ this will create the website [https://jorgemarpa.github.io/repo-template/](https
9897
## GitHub Actions
9998

10099
This are automatic actions that happens during pushing new commits and/or pull request. We can configure these actions in a `yml` file in the `.github/workflows` directory.
101-
In this template we have one for `ruff`, `deploy-mkdocs`, `pytest`, and `dependabot`.
100+
In this template we have one for `ruff`, `deploy-mkdocs`, `pytest`, `dependabot`, and `mypy`.
101+
102+
### Publish to PyPI Action
103+
104+
This repo has the action `pypi-publish.yml` that automatically publish the package to TestPyPI once a
105+
release or a tag version is created in GitHub. Note that for this example we used
106+
[TestPyPI](https://test.pypi.org/) which is an instance of PyPI to test package deplyment and publishing
107+
withou afecting the real index. It is ideal to test things.
108+
We also need to setup a TestPyPI/PyPI API token and add it to GitHub secrets.
109+
110+
When our package is ready to be publish to the real PyPI, we need to update the action as follows:
111+
```
112+
- name: Config Poetry to testPyPI
113+
run: |
114+
poetry config repositories.test-pypi https://test.pypi.org/legacy/
115+
poetry config pypi-token.test-pypi "${{ secrets.TEST_PYPI_API_KEY }}"
116+
- name: Publish package to testPyPI
117+
run: poetry publish -r test-pypi --build
118+
```
119+
to
120+
```
121+
- name: Config Poetry to PyPI
122+
run: |
123+
poetry config pypi-token.pypi "${{ secrets.PYPI_API_KEY }}"
124+
- name: Publish package to testPyPI
125+
run: poetry publish --build
126+
```
127+
This will change te repository configuration back to publish to PyPI. Remember to add the PyPI
128+
API token to GitHub secrets.
129+
130+
See this [tutorial](https://www.ianwootten.co.uk/2020/10/23/publishing-to-pypi-using-github-actions/) for more details.
102131

103132
## Pytest
104133

0 commit comments

Comments
 (0)