1- name : Build
2-
3- on : [push, pull_request]
1+ name : Build Wheels
2+ on :
3+ push :
4+ branches :
5+ - main # Build on pushes to main
6+ pull_request :
7+ branches :
8+ - main
9+ release :
10+ types : [published]
411
512jobs :
613 build_wheels :
7- name : Build wheels on ${{ matrix.os }}
8- runs-on : ${{ matrix.os }}
14+ name : Build wheels on ${{ matrix.buildplat[0] }} (${{ matrix.buildplat[1] }})
15+ runs-on : ${{ matrix.buildplat[0] }}
916 strategy :
17+ fail-fast : false
1018 matrix :
11- os : [windows-latest,ubuntu-latest,macos-12]
12- include :
13- - os : ubuntu-latest
14- python-version : ' 3.12'
15- toolchain : {compiler: gcc, version: 13}
16- - os : macos-12
17- python-version : ' 3.12'
18- toolchain : {compiler: gcc, version: 13}
19- - os : windows-latest
20- python-version : ' 3.11'
21- toolchain : {compiler: gcc, version: 13}
22-
19+ buildplat :
20+ - [ "ubuntu-latest", "auto", "", 'FC="gfortran" CC="gcc" CXX="g++"' ]
21+ - [ "windows-latest", "AMD64", "MINGW64", 'FC="gfortran" CC="gcc" CXX="g++"' ]
22+ - [ "macos-13", "x86_64", "", 'MACOSX_DEPLOYMENT_TARGET=13.0 FC="gfortran" CC="gcc" CXX="g++"' ]
23+ - [ "macos-14", "arm64", "", 'MACOSX_DEPLOYMENT_TARGET=14.0 FC="gfortran" CC="gcc" CXX="g++"' ]
24+ - [ "macos-15", "arm64", "", 'MACOSX_DEPLOYMENT_TARGET=15.0 FC="gfortran" CC="gcc" CXX="g++"' ]
25+
2326 steps :
2427 - name : Checkout code
2528 uses : actions/checkout@v4
2629
27- - name : Install Fortran compiler for Unix
28- if : runner.os != 'Windows '
30+ - name : Install Fortran compiler (Linux/macOS)
31+ if : runner.os == 'Linux' || runner.os == 'macOS '
2932 uses : awvwgk/setup-fortran@v1
3033 with :
31- compiler : ${{ matrix.toolchain.compiler }}
32- version : ${{ matrix.toolchain.version }}
34+ compiler : gcc
35+ version : ' latest '
3336
34- - name : Install Fortran compiler on Windows
37+ - name : Set up MSYS2 for Fortran ( Windows)
3538 if : runner.os == 'Windows'
36- run : |
37- Set-ExecutionPolicy Bypass -Scope Process -Force
38- [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
39- iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
40- choco install gcc
41- choco install make
42- shell : pwsh
43-
44- - name : Set up Python
45- uses : actions/setup-python@v4
39+ uses : msys2/setup-msys2@v2
4640 with :
47- python-version : ${{ matrix.python-version }}
41+ msystem : ${{ matrix.buildplat[2] }}
42+ update : true
43+ install : mingw-w64-x86_64-gcc-fortran
44+ path-type : inherit
4845
4946 - name : Build wheels
50- uses : pypa/cibuildwheel@v2.16.5
47+ uses : pypa/cibuildwheel@v2.19.2
5148 env :
52- PYTHONIOENCODING : utf-8
53- CIBW_ARCHS_WINDOWS : x86 auto64
54- CIBW_ARCHS_MACOS : x86_64
49+ CIBW_ARCHS : ${{ matrix.buildplat[1] }}
50+ CIBW_ENVIRONMENT : ${{ matrix.buildplat[3] }}
5551 with :
56- package-dir : .
5752 output-dir : wheelhouse
5853 config-file : " ./pyproject.toml"
5954
60- - name : Install Wheel
61- env :
62- PYTHONIOENCODING : utf-8
55+ - name : Upload wheels
56+ uses : actions/upload-artifact@v4
57+ with :
58+ name : cibw-wheels-${{ matrix.buildplat[0] }}-${{ matrix.buildplat[1] }}
59+ path : ./wheelhouse/*.whl
60+
61+ publish-wheels-to-repo :
62+ name : Commit Wheels to Repository
63+ needs : build_wheels
64+ runs-on : ubuntu-latest
65+ permissions :
66+ contents : write
67+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
68+ steps :
69+ - name : Checkout code
70+ uses : actions/checkout@v4
71+ - name : Download all wheel artifacts
72+ uses : actions/download-artifact@v4
73+ with :
74+ path : ./dist
75+ pattern : cibw-wheels-*
76+ merge-multiple : true
77+ - name : Commit and push wheels
6378 run : |
64- python -m venv venv
65- if [ $RUNNER_OS = 'Windows' ]; then
66- .\\venv\\Scripts\\activate
79+ git config --global user.name 'github-actions[bot]'
80+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
81+ git add ./dist/*.whl
82+ if git diff --staged --quiet; then
83+ echo "No new wheels to commit."
6784 else
68- source venv/bin/activate
85+ git commit -m "ci: Add built wheels [skip ci]"
86+ git push
6987 fi
70- for wheel in wheelhouse/*.whl; do
71- if ! pip install "$wheel"; then
72- echo "Failed to install $wheel, skipping..."
73- fi
74- done
75- shell : bash
7688
77- - name : Run tests
78- env :
79- PYTHONIOENCODING : utf-8
89+ publish-to-testpypi :
90+ name : Publish to TestPyPI
91+ needs : build_wheels
92+ runs-on : ubuntu-latest
93+ if : github.event_name == 'push'
94+ steps :
95+ - name : Download all wheel artifacts
96+ uses : actions/download-artifact@v4
97+ with :
98+ path : ./dist
99+ pattern : cibw-wheels-*
100+ merge-multiple : true
101+ - name : Publish package to TestPyPI
102+ uses : pypa/gh-action-pypi-publish@release/v1
103+ with :
104+ password : ${{ secrets.TestPYPI_API_TOKEN }}
105+ repository-url : https://test.pypi.org/legacy/
106+ skip-existing : true
107+
108+ publish-to-pypi :
109+ name : Publish to PyPI
110+ needs : build_wheels
111+ runs-on : ubuntu-latest
112+ if : github.event_name == 'release' && github.event.action == 'published'
113+
114+ steps :
115+ - name : Download all wheel artifacts
116+ uses : actions/download-artifact@v4
117+ with :
118+ path : ./dist
119+
120+ - name : Move and organize wheels
80121 run : |
81- if [ $RUNNER_OS = 'Windows' ]; then
82- .\\venv\\Scripts\\activate
83- else
84- source venv/bin/activate
85- fi
86- cd test
87- for test in Test*.py; do
88- python "$test"
89- done
90- shell : bash
122+ find ./dist -name "*.whl" -exec mv {} ./dist/ \;
123+ find ./dist -mindepth 1 -type d -exec rm -rf {} +
91124
92- - uses : actions/upload-artifact@v4
125+ - name : Publish package to PyPI
126+ uses : pypa/gh-action-pypi-publish@release/v1
93127 with :
94- name : cibw-wheels- ${{ matrix.os }}-${{ strategy.job-index }}
95- path : ./wheelhouse/*.whl
128+ password : ${{ secrets.PYPI_API_TOKEN }}
129+ packages-dir : ./dist/
0 commit comments