Skip to content

Commit e5ec6c2

Browse files
committed
47 | Update publish workflow to include .whl
1 parent 281ac4c commit e5ec6c2

File tree

2 files changed

+86
-18
lines changed

2 files changed

+86
-18
lines changed
Lines changed: 73 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,52 @@
11
name: Publish to PyPI
22

3-
on:
4-
release:
5-
types: [published]
3+
on: [push]
4+
# release:
5+
# types: [published]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
610

711
jobs:
8-
publish:
12+
13+
build-newer-whl:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ ubuntu-latest, windows-latest, macos-latest ]
18+
python: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
19+
exclude:
20+
- os: macos-latest
21+
python: "3.9"
22+
- os: macos-latest
23+
python: "3.8"
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python }}
31+
32+
- name: Install build tools
33+
run: pip install build twine wheel
34+
35+
- name: Build wheel
36+
run: python -m build --wheel
37+
38+
- name: Upload built packages
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: pkg-${{ matrix.os }}-${{ matrix.python }}-${{ strategy.job-index }}
42+
path: |
43+
./dist/*.whl
44+
45+
build-sdist:
946
runs-on: ubuntu-latest
1047

1148
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
49+
- uses: actions/checkout@v4
1450

1551
- uses: actions/setup-python@v5
1652
with:
@@ -19,11 +55,35 @@ jobs:
1955
- name: Install build tools
2056
run: pip install build twine wheel
2157

22-
- name: Build package
23-
run: python -m build
58+
- name: Build source distribution
59+
run: python -m build --sdist
60+
61+
- name: Upload built packages
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: pkg-sdist
65+
path: |
66+
./dist/*.tar.gz
67+
68+
publish:
69+
needs: [build-older-whl, build-newer-whl, build-sdist]
70+
runs-on: ubuntu-latest
71+
72+
environment:
73+
name: release
74+
url: https://pypi.org/project/flask-inputfilter
75+
76+
permissions:
77+
id-token: write
78+
79+
steps:
80+
- name: Download built packages
81+
uses: actions/download-artifact@v4
82+
with:
83+
path: dist
84+
merge-multiple: true
2485

25-
- name: Publish to PyPI
26-
env:
27-
TWINE_USERNAME: __token__
28-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
29-
run: twine upload dist/*.tar.gz
86+
- name: Publish package to PyPI
87+
#uses: pypa/gh-action-pypi-publish@release/v1
88+
run: |
89+
ls -la dist

setup.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44

55
if shutil.which("g++") is not None:
66
from Cython.Build import cythonize
7+
from setuptools.extension import Extension
8+
9+
pyx_modules = [
10+
"flask_inputfilter.Mixin._ExternalApiMixin",
11+
"flask_inputfilter.Model._FieldModel",
12+
"flask_inputfilter._InputFilter",
13+
]
714

815
ext_modules = cythonize(
9-
[
10-
"flask_inputfilter/Mixin/_ExternalApiMixin.pyx",
11-
"flask_inputfilter/Model/_FieldModel.pyx",
12-
"flask_inputfilter/_InputFilter.pyx",
13-
],
16+
module_list=[Extension(
17+
name=module,
18+
sources=[module.replace('.', '/') + ".pyx"],
19+
extra_compile_args=["-std=c++11"],
20+
language="c++"
21+
) for module in pyx_modules],
1422
language_level=3,
1523
)
1624
options = {

0 commit comments

Comments
 (0)