|
| 1 | +name: Build Wheels & Publish to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + release: |
| 7 | + types: [published] |
| 8 | + |
| 9 | +env: |
| 10 | + USE_BAZEL_VERSION: "7.6.1" |
| 11 | + |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: > |
| 16 | + build ${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} |
| 17 | + ${{ (matrix.arch) || '' }} |
| 18 | + strategy: |
| 19 | + # fail-fast: true |
| 20 | + matrix: |
| 21 | + os: [ubuntu] |
| 22 | + python-version: ['3.9', '3.10', '3.11', '3.12'] |
| 23 | + |
| 24 | + |
| 25 | + runs-on: ${{ format('{0}-latest', matrix.os) }} |
| 26 | + steps: |
| 27 | + - name: Check out the repo |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Set up python |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | + |
| 35 | + - name: Install python build dependencies |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip build |
| 38 | +
|
| 39 | + - name: Build wheels |
| 40 | + run: | |
| 41 | + python -m build --wheel --sdist |
| 42 | + mkdir wheelhouse |
| 43 | + mv dist/* wheelhouse/ |
| 44 | +
|
| 45 | + - name: List and check wheels |
| 46 | + run: | |
| 47 | + pip install twine pkginfo>=1.11.0 |
| 48 | + ${{ matrix.ls || 'ls -lh' }} wheelhouse/ |
| 49 | + twine check wheelhouse/* |
| 50 | +
|
| 51 | + - name: Upload wheels |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: build-${{ matrix.python-version }}-${{ matrix.os }} |
| 55 | + path: ./wheelhouse/* |
| 56 | + |
| 57 | + upload_to_pypi: |
| 58 | + name: Upload to PyPI |
| 59 | + runs-on: ubuntu-latest |
| 60 | + if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch') |
| 61 | + needs: [build] |
| 62 | + environment: |
| 63 | + name: pypi |
| 64 | + url: https://pypi.org/p/tensorflow-metadata |
| 65 | + permissions: |
| 66 | + id-token: write |
| 67 | + steps: |
| 68 | + - name: Retrieve wheels and sdist |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + merge-multiple: true |
| 72 | + path: wheels/ |
| 73 | + |
| 74 | + - name: List the build artifacts |
| 75 | + run: | |
| 76 | + ls -lAs wheels/ |
| 77 | +
|
| 78 | + - name: Upload to PyPI |
| 79 | + uses: pypa/gh-action-pypi-publish@release/v1.12 |
| 80 | + with: |
| 81 | + packages-dir: wheels/ |
| 82 | + repository-url: https://pypi.org/legacy/ |
| 83 | + # already checked, and the pkginfo/twine versions on this runner causes check to fail |
| 84 | + verify-metadata: false |
| 85 | + verbose: true |
0 commit comments