|
| 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. |
| 7 | +name: Build Wheels |
| 8 | + |
| 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 |
| 20 | + |
| 21 | +# TODO-TEMPLATE: Populate environment variables below |
| 22 | +# LIBRARY_BASE_REPO: The base repo with the C++ implementation, e.g. "NTIA/itm" |
| 23 | +# LIBRARY_RELEASE_TAG: The Git tag identifying a release. Can be a pre-release. |
| 24 | +# LIBRARY_DESTINATION_DIRECTORY: Path in this repo where shared library files should be placed |
| 25 | +env: |
| 26 | + LIBRARY_BASE_REPO: NTIA/proplib-template |
| 27 | + LIBRARY_RELEASE_TAG: v1.0 |
| 28 | + LIBRARY_DESTINATION_DIRECTORY: 'src/ITS/PropLibTemplate/' |
| 29 | + |
| 30 | +jobs: |
| 31 | + build_wheel: |
| 32 | + name: Build a universal, cross-platform wheel |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Check out repository |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + submodules: true |
| 39 | + |
| 40 | + # Only the binaries required for the current platform are downloaded. Note that the distributed |
| 41 | + # wheel for proplib python packages includes all binaries, so that the wheel is inherently cross-platform. |
| 42 | + - name: Download required ${{ env.LIBRARY_RELEASE_TAG }} Windows binaries |
| 43 | + uses: robinraju/release-downloader@v1 |
| 44 | + with: |
| 45 | + repository: ${{ env.LIBRARY_BASE_REPO }} |
| 46 | + tag: ${{ env.LIBRARY_RELEASE_TAG }} |
| 47 | + fileName: '*.dll' |
| 48 | + tarBall: false |
| 49 | + zipBall: false |
| 50 | + out-file-path: ${{ env.LIBRARY_DESTINATION_DIRECTORY }} |
| 51 | + |
| 52 | + - name: Download required ${{ env.LIBRARY_RELEASE_TAG }} Linux binaries |
| 53 | + uses: robinraju/release-downloader@v1 |
| 54 | + with: |
| 55 | + repository: ${{ env.LIBRARY_BASE_REPO }} |
| 56 | + tag: ${{ env.LIBRARY_RELEASE_TAG }} |
| 57 | + fileName: '*.so' |
| 58 | + tarBall: false |
| 59 | + zipBall: false |
| 60 | + out-file-path: ${{ env.LIBRARY_DESTINATION_DIRECTORY }} |
| 61 | + |
| 62 | + - name: Download required ${{ env.LIBRARY_RELEASE_TAG }} macOS binaries |
| 63 | + uses: robinraju/release-downloader@v1 |
| 64 | + with: |
| 65 | + repository: ${{ env.LIBRARY_BASE_REPO }} |
| 66 | + tag: ${{ env.LIBRARY_RELEASE_TAG }} |
| 67 | + fileName: '*.dylib' |
| 68 | + tarBall: false |
| 69 | + zipBall: false |
| 70 | + out-file-path: ${{ env.LIBRARY_DESTINATION_DIRECTORY }} |
| 71 | + |
| 72 | + - name: Set up Python |
| 73 | + uses: actions/setup-python@v5 |
| 74 | + with: |
| 75 | + python-version: '3.13' |
| 76 | + |
| 77 | + - name: Install build dependencies |
| 78 | + run: pip install hatchling |
| 79 | + |
| 80 | + - name: Build wheels |
| 81 | + run: hatchling build |
| 82 | + |
| 83 | + - uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: Universal Wheel (.whl) |
| 86 | + path: dist/*.whl |
0 commit comments