-
-
Notifications
You must be signed in to change notification settings - Fork 103
69 lines (60 loc) · 2.25 KB
/
publish-api-rate-limiter.yml
File metadata and controls
69 lines (60 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# =============================================================================
# AngelaMos | 2026
# publish-api-rate-limiter.yml
# =============================================================================
name: Publish api-rate-limiter to PyPI
on:
push:
branches:
- main
paths:
- 'PROJECTS/advanced/api-rate-limiter/**'
- '!PROJECTS/advanced/api-rate-limiter/README.md'
- '!PROJECTS/advanced/api-rate-limiter/justfile'
- '!PROJECTS/advanced/api-rate-limiter/learn/**'
- '!PROJECTS/advanced/api-rate-limiter/examples/**'
permissions:
contents: read
jobs:
pypi-publish:
name: Upload api-rate-limiter to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/fastapi-420
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Check if version exists on PyPI
id: version_check
working-directory: PROJECTS/advanced/api-rate-limiter
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/fastapi-420/${VERSION}/json")
if [ "$STATUS" = "200" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "::notice::fastapi-420 v${VERSION} already on PyPI — skipping publish"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "::notice::fastapi-420 v${VERSION} not on PyPI — publishing"
fi
- name: Install build dependencies
if: steps.version_check.outputs.exists != 'true'
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
if: steps.version_check.outputs.exists != 'true'
working-directory: PROJECTS/advanced/api-rate-limiter
run: python -m build
- name: Publish to PyPI
if: steps.version_check.outputs.exists != 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: PROJECTS/advanced/api-rate-limiter/dist/