1- # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2- # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
4- name : jsonobject tests
1+ name : Wheels
52
63on :
74 push :
8- branches : [ master ]
9- pull_request :
5+ branches :
6+ - master
7+ tags :
8+ - " v*"
9+ workflow_dispatch :
1010
1111jobs :
1212 configure :
@@ -15,39 +15,123 @@ jobs:
1515 - uses : actions/checkout@v4
1616 - name : Read Python versions from pyproject.toml
1717 id : read-versions
18- # produces output like: python_versions=[ "3.9", "3.10", "3.11", "3.12" ]
18+ # produces output like: python_versions=39,310,311,312,313
1919 run : >-
2020 echo "python_versions=$(
21- grep -oP '(?<=Language :: Python :: )\d\. \d+' pyproject.toml
22- | jq --raw-input .
23- | jq --slurp .
24- | tr '\n' ' '
21+ grep -oP '(?<= :: Python :: )(\d).( \d+) ' pyproject.toml
22+ | sed 's/\.//'
23+ | tr '\n' ','
24+ | sed 's/,$// '
2525 )" >> $GITHUB_OUTPUT
2626 outputs :
2727 python_versions : ${{ steps.read-versions.outputs.python_versions }}
2828
29- build :
30- needs : [configure]
29+ build_sdist :
30+ name : Build source distribution
31+ runs-on : ubuntu-latest
32+ steps :
33+ - uses : actions/checkout@v4
34+ - name : Check version
35+ if : ${{ startsWith(github.ref, 'refs/tags/v') }}
36+ run : python version.py check "${{ github.ref }}"
37+ - name : Add untagged version suffix
38+ if : ${{ ! startsWith(github.ref, 'refs/tags/v') }}
39+ run : python version.py update ${{ github.sha }}
40+ - name : Build sdist
41+ run : pipx run build --sdist
42+ - uses : actions/upload-artifact@v4
43+ with :
44+ name : sdist
45+ path : dist
46+
47+ choose_linux_wheel_types :
48+ name : Decide which wheel types to build
49+ runs-on : ubuntu-latest
50+ steps :
51+ - id : manylinux_x86_64
52+ run : echo "wheel_types=manylinux_x86_64" >> $GITHUB_OUTPUT
53+ - id : musllinux_x86_64
54+ run : echo "wheel_types=musllinux_x86_64" >> $GITHUB_OUTPUT
55+ outputs :
56+ wheel_types : ${{ toJSON(steps.*.outputs.wheel_types) }}
57+
58+ build_linux_wheels :
59+ needs : [configure, choose_linux_wheel_types]
60+ name : ${{ matrix.wheel_type }} wheels
3161 runs-on : ubuntu-latest
3262 strategy :
33- fail-fast : false
3463 matrix :
35- python-version : ${{ fromJSON(needs.configure.outputs.python_versions) }}
64+ wheel_type : ${{ fromJSON(needs.choose_linux_wheel_types.outputs.wheel_types) }}
65+ steps :
66+ - uses : actions/download-artifact@v4
67+ with :
68+ name : sdist
69+ path : dist
70+ - name : Extract sdist
71+ run : |
72+ tar zxvf dist/*.tar.gz --strip-components=1
73+ - uses : docker/setup-qemu-action@v3
74+ if : runner.os == 'Linux'
75+ name : Set up QEMU
76+ - name : Disable ptrace security restrictions
77+ run : |
78+ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
79+ - name : Build wheels
80+ uses : pypa/cibuildwheel@v2.22.0
81+ env :
82+ CIBW_BUILD : cp{${{ needs.configure.outputs.python_versions }}}-${{ matrix.wheel_type }}
83+ CIBW_ARCHS_LINUX : auto
84+ CIBW_TEST_COMMAND : python -m unittest
85+ - uses : actions/upload-artifact@v4
86+ with :
87+ name : ${{ matrix.wheel_type }}-wheels
88+ path : ./wheelhouse/*.whl
3689
90+ pypi-publish :
91+ name : Upload release to PyPI
92+ needs : [build_sdist, build_linux_wheels]
93+ runs-on : ubuntu-latest
94+ if : startsWith(github.ref, 'refs/tags/v')
95+ environment :
96+ name : pypi
97+ url : https://pypi.org/p/pytest-unmagic
98+ permissions :
99+ id-token : write
37100 steps :
38- - uses : actions/checkout@v4
39- - name : Set up Python ${{ matrix.python-version }}
40- uses : actions/setup-python@v5
41- with :
42- python-version : ${{ matrix.python-version }}
43- - name : Install dependencies
44- run : |
45- python -m pip install --upgrade pip
46- python -m pip install -e .
47- - name : Run tests
48- run : |
49- python -m unittest
50- - name : Test cython files
51- run : |
52- scripts/install_cython.sh
53- scripts/test_cython_files.sh
101+ - name : Download all the dists
102+ uses : actions/download-artifact@v4
103+ with :
104+ name : python-package-distributions
105+ path : dist/
106+ - run : |
107+ mv dist/sdist/*.tar.gz dist/
108+ mv dist/*-wheels/*.whl dist/
109+ rmdir dist/{sdist,*-wheels}
110+ ls -R dist
111+ - name : Publish package distributions to PyPI
112+ uses : pypa/gh-action-pypi-publish@release/v1
113+
114+ pypi-test-publish :
115+ name : Upload release to test PyPI
116+ needs : [build_sdist, build_linux_wheels]
117+ runs-on : ubuntu-latest
118+ environment :
119+ name : testpypi
120+ url : https://test.pypi.org/p/pytest-unmagic
121+ permissions :
122+ id-token : write
123+ steps :
124+ - name : Download all the dists
125+ uses : actions/download-artifact@v4
126+ with :
127+ name : python-package-distributions
128+ path : dist/
129+ - run : |
130+ mv dist/sdist/*.tar.gz dist/
131+ mv dist/*-wheels/*.whl dist/
132+ rmdir dist/{sdist,*-wheels}
133+ ls -R dist
134+ - name : Publish package distributions to PyPI
135+ uses : pypa/gh-action-pypi-publish@release/v1
136+ with :
137+ repository-url : https://test.pypi.org/legacy/
0 commit comments