|
1 | 1 | # Template Repo |
2 | 2 |
|
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 | +[](https://test.pypi.org/project/repo-template) |
| 4 | +[](https://github.com/jorgemarpa/repo-template/actions/workflows/pytest.yml/) [](https://github.com/jorgemarpa/repo-template/actions/workflows/mypy.yml) [](https://github.com/jorgemarpa/repo-template/actions/workflows/ruff.yml)[](https://github.com/jorgemarpa/repo-template/actions/workflows/deploy-mkdocs.yml) |
6 | 5 |
|
7 | 6 | 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. |
8 | 7 |
|
@@ -98,7 +97,37 @@ this will create the website [https://jorgemarpa.github.io/repo-template/](https |
98 | 97 | ## GitHub Actions |
99 | 98 |
|
100 | 99 | 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. |
102 | 131 |
|
103 | 132 | ## Pytest |
104 | 133 |
|
|
0 commit comments