Skip to content

Commit bcde4cf

Browse files
authored
📦 [GH-71] Add PyPi GitHub Action releases (#72)
* feat: add pypi release to GitHub Action [#71] * docs: update README [#71] * chore: add version to docs and test docs step [#71]
1 parent 1511de7 commit bcde4cf

File tree

7 files changed

+64
-12
lines changed

7 files changed

+64
-12
lines changed

.github/workflows/main.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,32 @@ jobs:
2727
branch: "master"
2828
secrets:
2929
token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
upload-release-to-pypi:
32+
if: startsWith(github.ref, 'refs/tags/')
33+
needs: [create-release]
34+
name: upload release to PyPI
35+
runs-on: ubuntu-latest
36+
environment: pypi
37+
permissions:
38+
id-token: write
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v6
44+
with:
45+
# Install a specific version of uv.
46+
version: "0.7.18"
47+
48+
- name: Set up Python
49+
run: uv python install
50+
51+
- name: Install the project
52+
run: uv sync
53+
54+
- name: Build the package
55+
run: uv build
56+
57+
- name: Publish package distributions to PyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ jobs:
3333
- name: Install the project
3434
run: uv sync
3535

36-
- name: Run tests 📉
36+
- name: Run unit tests 📉
3737
run: make pytest
3838

39+
- name: Tests sphinx 📚
40+
run: make sphinx
41+
3942
docker:
4043
strategy:
4144
fail-fast: false

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<a href="https://github.com/nickatnight/cookiecutter-fastapi-backend/actions">
33
<img alt="GitHub Actions status" src="https://github.com/nickatnight/cookiecutter-fastapi-backend/actions/workflows/main.yml/badge.svg">
44
</a>
5-
<a href="https://github.com/nickatnight/cookiecutter-fastapi-backend/releases"><img alt="Release Status" src="https://img.shields.io/github/v/release/nickatnight/cookiecutter-fastapi-backend"></a>
5+
<a href="https://pypi.org/project/cookiecutter-fastapi-backend/">
6+
<img alt="PyPi Shield" src="https://img.shields.io/pypi/v/cookiecutter-fastapi-backend">
7+
</a>
68
<a href="https://github.com/nickatnight/cookiecutter-fastapi-backend/blob/master/LICENSE">
79
<img alt="License Shield" src="https://img.shields.io/github/license/nickatnight/cookiecutter-fastapi-backend">
810
</a>
@@ -16,11 +18,10 @@
1618
[Cookiecutter](https://github.com/cookiecutter/cookiecutter) template to build and deploy fastapi backends to your favorite PaaS..batteries included.
1719

1820
Supported PaaS's:
19-
- Render.com
21+
- Render
2022
- Platform.sh (Coming soon)
2123
- Porter (Coming soon)
2224
- Fly.io (Coming soon)
23-
- AWS (Coming soon)
2425
- DigitalOcean (Coming soon)
2526

2627
## Quickstart
@@ -29,9 +30,18 @@ Install the latest Cookiecutter if you haven't installed it yet (this requires C
2930
pip install cookiecutter
3031
```
3132

32-
Generate project:
33+
Generate project from GitHub template:
34+
3335
```sh
34-
cookiecutter https://github.com/nickatnight/cookiecutter-fastapi-backend.git
36+
$ cookiecutter gh:nickatnight/cookiecutter-fastapi-backend.git
37+
```
38+
39+
Or from Python code:
40+
41+
```python
42+
from cookiecutter.main import cookiecutter
43+
44+
cookiecutter("gh:nickatnight/cookiecutter-fastapi-backend.git")
3545
```
3646

3747
## Features
@@ -54,7 +64,7 @@ The input variables, with their default values (some auto generated) are:
5464
* `project_name`: The name of the project
5565
* `project_slug`: The development friendly name of the project. By default, based on the project name
5666
* `project_slug_db`: The database friendly name of the project. By default, based on the project name
57-
* `author_email`: The authors email...used for certbot
67+
* `author_email`: The authors email...for maintainer info in `pyproject.toml`
5868
* `py_version`: The version of Python to install. Options are `3.9`, `3.10`, and `3.11`
5969
* `db_container_name`: The name of the database container. Default `db`
6070
* `backend_container_name`: The name of the backend container. Default `backend`

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ text-unidecode==1.3 \
396396
--hash=sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8 \
397397
--hash=sha256:bad6603bb14d279193107714b288be206cac565dfa49aa5b105294dd5c4aab93
398398
# via python-slugify
399-
tomli==2.2.1 ; python_full_version < '3.11' \
399+
tomli==2.2.1 \
400400
--hash=sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6 \
401401
--hash=sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd \
402402
--hash=sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c \

docs/source/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@
88
from datetime import datetime
99
from typing import Any
1010

11+
import tomli
12+
1113
# -- Project information -----------------------------------------------------
1214
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
1315
sys.path.insert(0, ".")
1416
sys.path.append(os.path.abspath("../.."))
1517

1618

19+
with open("../../pyproject.toml", "rb") as f:
20+
toml_dict = tomli.load(f)
21+
1722
project = "Cookiecutter FastAPI Backend"
1823
author = "Nick Kelly"
1924
copyright = datetime.today().strftime(f"%Y, {author}")
25+
release = toml_dict["project"]["version"]
26+
version = ".".join(release.split(".", 2)[:2])
2027

2128
# -- General configuration ---------------------------------------------------
2229
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cookiecutter-fastapi-backend"
3-
version = "2.1.0"
3+
version = "2.2.0"
44
description = "Cookiecutter template to build and deploy fastapi backends..batteries included"
55
authors = [{ name = "nickatnight", email = "nialexanderke@proton.me" }]
66
requires-python = ">=3.9"
@@ -9,13 +9,14 @@ dependencies = [
99
"cookiecutter==2.6.0",
1010
]
1111
classifiers = [
12+
"Framework :: FastAPI",
1213
"Intended Audience :: Developers",
1314
"Programming Language :: Python :: 3",
1415
"Programming Language :: Python :: 3.10",
1516
"Programming Language :: Python :: 3.11",
1617
"Programming Language :: Python :: 3.12",
1718
"Programming Language :: Python :: 3.13",
18-
"Topic :: Software Development :: Libraries :: Python Modules"
19+
"Topic :: Software Development :: Code Generators"
1920
]
2021

2122
[project.urls]
@@ -33,11 +34,11 @@ dev = [
3334
"sphinx==7.4.7",
3435
"sphinx-rtd-theme==3.0.1",
3536
"sphinx-rtd-dark-mode==1.3.0",
37+
"tomli==2.2.1",
3638
"typing-extensions==4.14.0"
3739
]
3840

3941
[tool.uv]
40-
package = false
4142
required-version = ">=0.7.18"
4243

4344
[tool.ruff]

uv.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)