Skip to content

Commit cf134b0

Browse files
authored
Merge pull request #48 from LeanderCS/47
47 | Update publish workflow to include .whl
2 parents 281ac4c + ba89c08 commit cf134b0

File tree

5 files changed

+107
-17
lines changed

5 files changed

+107
-17
lines changed

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

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,65 @@ 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: [ 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.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
50+
51+
- name: Build wheel
52+
run: python -m build --wheel
53+
54+
- name: Upload built packages
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: pkg-${{ matrix.os }}-${{ matrix.python }}-${{ strategy.job-index }}
58+
path: |
59+
./dist/*.whl
60+
61+
build-sdist:
962
runs-on: ubuntu-latest
1063

1164
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
65+
- uses: actions/checkout@v4
1466

1567
- uses: actions/setup-python@v5
1668
with:
@@ -19,11 +71,33 @@ jobs:
1971
- name: Install build tools
2072
run: pip install build twine wheel
2173

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

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
102+
- name: Publish package to PyPI
103+
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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)