Skip to content

Commit 75582c0

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

File tree

2 files changed

+104
-18
lines changed

2 files changed

+104
-18
lines changed
Lines changed: 91 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,70 @@
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-whl:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ ubuntu-latest, windows-latest, macos-latest ]
18+
python: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
19+
exclude:
20+
- os: windows-latest
21+
python: "3.14"
22+
#- os: macos-latest
23+
# python: "3.9"
24+
- os: macos-latest
25+
python: "3.8"
26+
- os: macos-latest
27+
python: "3.7"
28+
- os: ubuntu-latest
29+
python: "3.7"
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install Python 3.14 with pyenv (if needed)
35+
if: ${{ matrix.python == '3.14' }}
36+
run: |
37+
curl https://pyenv.run | bash
38+
export PATH="$HOME/.pyenv/bin:$PATH"
39+
eval "$(pyenv init --path)"
40+
eval "$(pyenv init -)"
41+
pyenv install 3.14-dev
42+
pyenv global 3.14-dev
43+
44+
- name: Setup Python
45+
if: ${{ matrix.python != '3.14' }}
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: ${{ matrix.python }}
49+
50+
- name: Install build tools
51+
run: pip install build twine wheel
52+
53+
- name: Build wheel
54+
run: python -m build --wheel
55+
56+
- name: Upload built packages
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: pkg-${{ matrix.os }}-${{ matrix.python }}-${{ strategy.job-index }}
60+
path: |
61+
./dist/*.whl
62+
63+
build-sdist:
964
runs-on: ubuntu-latest
1065

1166
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
67+
- uses: actions/checkout@v4
1468

1569
- uses: actions/setup-python@v5
1670
with:
@@ -19,11 +73,35 @@ jobs:
1973
- name: Install build tools
2074
run: pip install build twine wheel
2175

22-
- name: Build package
23-
run: python -m build
76+
- name: Build source distribution
77+
run: python -m build --sdist
78+
79+
- name: Upload built packages
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: pkg-sdist
83+
path: |
84+
./dist/*.tar.gz
85+
86+
publish:
87+
needs: [build-whl, build-sdist]
88+
runs-on: ubuntu-latest
89+
90+
environment:
91+
name: release
92+
url: https://pypi.org/project/flask-inputfilter
93+
94+
permissions:
95+
id-token: write
96+
97+
steps:
98+
- name: Download built packages
99+
uses: actions/download-artifact@v4
100+
with:
101+
path: dist
102+
merge-multiple: true
24103

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
104+
- name: Publish package to PyPI
105+
#uses: pypa/gh-action-pypi-publish@release/v1
106+
run: |
107+
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)