|
| 1 | +# Action builds a universal (Win32/Win64/macOS-universal/Linux-x64) Python wheel |
| 2 | +# from the source code, using Hatchling, and uploads it as an artifact. This wheel |
| 3 | +# can then be distributed with new releases. The action is triggered by pushes into `main` |
| 4 | +# or pull_requests into `main` or `dev` (for testing). To aid in releases, the workflow is |
| 5 | +# also triggered when new SemVer tags are created. This action handles downloading all |
| 6 | +# shared library files and including them in the resulting wheel. |
1 | 7 | name: Build Wheels |
2 | 8 |
|
3 | | -on: [push] # TODO |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + tags: |
| 15 | + - 'v[0-9]+.*' |
| 16 | + pull_request: |
| 17 | + branches: |
| 18 | + - main |
| 19 | + - dev |
4 | 20 |
|
5 | 21 | env: |
6 | 22 | LIBRARY_BASE_REPO: NTIA/p2108 |
|
62 | 78 |
|
63 | 79 | - uses: actions/upload-artifact@v4 |
64 | 80 | with: |
65 | | - name: universal-wheel |
| 81 | + name: Universal Wheel (.whl) |
66 | 82 | path: dist/*.whl |
67 | | - test_wheel: |
68 | | - name: Test wheel / ${{ matrix.platform.os-name }} |
69 | | - needs: build_wheel |
70 | | - runs-on: ${{ matrix.platform.os-runner }} |
71 | | - strategy: |
72 | | - matrix: |
73 | | - platform: |
74 | | - - os-name: 'Windows (64-bit)' |
75 | | - os-runner: 'windows-latest' |
76 | | - arch-id: 'x64' |
77 | | - release-file-pattern: '*-x64.dll' |
78 | | - - os-name: 'Windows (32-bit)' |
79 | | - os-runner: 'windows-latest' |
80 | | - arch-id: 'x86' |
81 | | - release-file-pattern: '*-x86.dll' |
82 | | - - os-name: 'macOS (intel/x64)' |
83 | | - os-runner: 'macos-13' |
84 | | - arch-id: 'x64' |
85 | | - release-file-pattern: '*.dylib' |
86 | | - - os-name: 'macOS (apple/arm64)' |
87 | | - os-runner: 'macos-latest' |
88 | | - arch-id: 'arm64' |
89 | | - release-file-pattern: '*.dylib' |
90 | | - - os-name: 'Linux (Ubuntu)' |
91 | | - os-runner: 'ubuntu-latest' |
92 | | - arch-id: 'x64' |
93 | | - release-file-pattern: '*.so' |
94 | | - steps: |
95 | | - - name: Check out repository |
96 | | - uses: actions/checkout@v4 |
97 | | - with: |
98 | | - submodules: true |
99 | | - |
100 | | - - name: Download wheel |
101 | | - id: wheel-download |
102 | | - uses: actions/download-artifact@v4 |
103 | | - |
104 | | - - name: debug list files |
105 | | - run: ls ${{ steps.wheel-download.outputs.download-path }}/universal-wheel/* |
106 | | - |
107 | | - - name: Set up Python |
108 | | - uses: actions/setup-python@v5 |
109 | | - with: |
110 | | - architecture: ${{ matrix.platform.arch-id }} |
111 | | - python-version: '>=3.9 <3.14' |
112 | | - cache: 'pip' |
113 | | - |
114 | | - - name: Install dependencies for testing |
115 | | - run: python -m pip install .[tests] |
116 | | - |
117 | | - - name: Remove source directory # make sure we are testing the wheel, not the cloned package |
118 | | - run: rm -r ./src |
119 | | - |
120 | | - - name: debug list files |
121 | | - run: ls ${{ steps.wheel-download.outputs.download-path }}/* |
122 | | - |
123 | | - - name: Install newly-built wheel (macOS/Linux) |
124 | | - if: ${{ runner.os != 'Windows'}} |
125 | | - run: python -m pip install ${{ steps.wheel-download.outputs.download-path }}/universal-wheel/*.whl --force-reinstall |
126 | | - |
127 | | - - name: Install newly-built wheel (Windows) |
128 | | - if: ${{ runner.os == 'Windows'}} |
129 | | - run: python -m pip install ${{ steps.wheel-download.outputs.download-path }}\universal-wheel\*.whl --force-reinstall |
130 | | - |
131 | | - - name: Run pytest |
132 | | - run: pytest --cov-report=term-missing --no-cov-on-fail --cov |
0 commit comments