Skip to content

Commit da75fbc

Browse files
committed
add publish.yml
1 parent 66bb9a2 commit da75fbc

1 file changed

Lines changed: 118 additions & 0 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: CI and PyPI publication
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
release:
8+
types: [published]
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
jobs:
18+
checks:
19+
name: Python ${{ matrix.python }} and JavaScript
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 20
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
python: ["3.11", "3.12", "3.13"]
26+
steps:
27+
- uses: actions/checkout@v7
28+
- uses: actions/setup-python@v7
29+
with:
30+
python-version: ${{ matrix.python }}
31+
- uses: actions/setup-node@v7
32+
with:
33+
node-version: "24"
34+
- name: Install test dependencies
35+
run: python -m pip install ".[test,test-outputs]" mypy
36+
- name: Check types
37+
run: mypy
38+
- name: Python tests
39+
# Starlette 0.49.3 uses an AnyIO alias deprecated in newer AnyIO.
40+
# Keep other warnings fatal, as required by pyproject.toml.
41+
run: >-
42+
python -m pytest tests/unit tests/integration -m "not package"
43+
--ignore=tests/integration/test_js_suite.py
44+
-W "ignore:The anyio.abc.BlockingPortal alias is deprecated:DeprecationWarning"
45+
- name: JavaScript tests
46+
run: node --test "tests/js/*.test.mjs"
47+
- name: Install browser
48+
if: matrix.python == '3.13'
49+
run: |
50+
python -m pip install playwright
51+
python -m playwright install --with-deps chromium
52+
- name: Browser tests
53+
if: matrix.python == '3.13'
54+
run: >-
55+
python -m pytest tests/e2e
56+
-W "ignore:The anyio.abc.BlockingPortal alias is deprecated:DeprecationWarning"
57+
58+
build:
59+
name: Build distributions
60+
needs: checks
61+
runs-on: ubuntu-latest
62+
timeout-minutes: 10
63+
steps:
64+
- uses: actions/checkout@v7
65+
- uses: actions/setup-python@v7
66+
with:
67+
python-version: "3.13"
68+
- name: Check release tag matches package version
69+
if: github.event_name == 'release'
70+
env:
71+
RELEASE_TAG: ${{ github.event.release.tag_name }}
72+
run: |
73+
python - <<'PY'
74+
import ast
75+
import os
76+
from pathlib import Path
77+
78+
tree = ast.parse(Path("src/func_to_web/config.py").read_text())
79+
version = next(
80+
ast.literal_eval(node.value)
81+
for node in tree.body
82+
if isinstance(node, ast.Assign)
83+
and any(isinstance(target, ast.Name) and target.id == "__version__"
84+
for target in node.targets)
85+
)
86+
expected = f"v{version}"
87+
if os.environ["RELEASE_TAG"] != expected:
88+
raise SystemExit(f"Release tag must be {expected}")
89+
PY
90+
- name: Build and validate metadata
91+
run: |
92+
python -m pip install build twine
93+
python -m build
94+
python -m twine check --strict dist/*
95+
- uses: actions/upload-artifact@v7
96+
with:
97+
name: distributions
98+
path: dist/*
99+
if-no-files-found: error
100+
101+
publish:
102+
name: Publish to PyPI
103+
if: github.event_name == 'release'
104+
needs: build
105+
runs-on: ubuntu-latest
106+
timeout-minutes: 10
107+
environment:
108+
name: pypi
109+
url: https://pypi.org/project/func-to-web/
110+
permissions:
111+
id-token: write
112+
steps:
113+
- uses: actions/download-artifact@v8
114+
with:
115+
name: distributions
116+
path: dist/
117+
- name: Publish with Trusted Publishing
118+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)