Skip to content

Commit b93ebf5

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

File tree

5 files changed

+112
-18
lines changed

5 files changed

+112
-18
lines changed

.github/workflows/publish-to-pypi.yaml

Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,69 @@ on:
44
release:
55
types: [published]
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
711
jobs:
8-
publish:
12+
13+
build-whl:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ windows-latest, macos-latest ] #ubuntu-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.8"
24+
- os: macos-latest
25+
python: "3.7"
26+
#- os: ubuntu-latest
27+
# python: "3.7"
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Install Python 3.14 with pyenv (if needed)
33+
if: ${{ matrix.python == '3.14' }}
34+
run: |
35+
curl https://pyenv.run | bash
36+
export PATH="$HOME/.pyenv/bin:$PATH"
37+
eval "$(pyenv init --path)"
38+
eval "$(pyenv init -)"
39+
pyenv install 3.14-dev
40+
pyenv global 3.14-dev
41+
42+
- name: Setup Python
43+
if: ${{ matrix.python != '3.14' }}
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python }}
47+
48+
- name: Install build tools
49+
run: pip install build twine wheel auditwheel
50+
51+
- name: Build wheel
52+
run: python -m build --wheel
53+
54+
- name: Repair the wheel for manylinux compatibility
55+
if: ${{ runner.os == 'Linux' }}
56+
run: auditwheel repair dist/*.whl -w dist/
57+
58+
- name: Upload built packages
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: pkg-${{ matrix.os }}-${{ matrix.python }}-${{ strategy.job-index }}
62+
path: |
63+
./dist/*.whl
64+
65+
build-sdist:
966
runs-on: ubuntu-latest
1067

1168
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
69+
- uses: actions/checkout@v4
1470

1571
- uses: actions/setup-python@v5
1672
with:
@@ -19,11 +75,33 @@ jobs:
1975
- name: Install build tools
2076
run: pip install build twine wheel
2177

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

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

docs/source/changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ Changelog
33

44
All notable changes to this project will be documented in this file.
55

6+
[0.4.2] - 2025-04-25
7+
--------------------
8+
9+
Added
10+
^^^^^
11+
- .whl generation for all major versions and envs.
12+
13+
614
[0.4.1] - 2025-04-24
715
--------------------
816

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project = "flask-inputfilter"
22
copyright = "2025, Leander Cain Slotosch"
33
author = "Leander Cain Slotosch"
4-
release = "0.4.1"
4+
release = "0.4.2"
55

66
extensions = ["sphinx_rtd_theme", "sphinx_design"]
77

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "cython"]
2+
requires = ["setuptools>=42", "wheel", "cython>=3.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "flask_inputfilter"
7-
version = "0.4.1"
7+
version = "0.4.2"
88
description = "A library to easily filter and validate input data in Flask applications"
99
readme = "README.rst"
1010
requires-python = ">=3.7"

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)