|
| 1 | +name: Build ml-metadata with Conda |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + os: [ubuntu-latest] |
| 19 | + python-version: ["3.9", "3.10", "3.11"] |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Setup Micromamba |
| 26 | + uses: mamba-org/setup-micromamba@v1 |
| 27 | + with: |
| 28 | + environment-file: ci/environment.yml |
| 29 | + cache-environment: true |
| 30 | + create-args: >- |
| 31 | + python=${{ matrix.python-version }} |
| 32 | +
|
| 33 | + - name: Display environment info |
| 34 | + shell: bash -l {0} |
| 35 | + run: | |
| 36 | + micromamba info |
| 37 | + micromamba list |
| 38 | +
|
| 39 | + - name: Install Bazel |
| 40 | + shell: bash -l {0} |
| 41 | + run: | |
| 42 | + # Install Bazelisk (manages Bazel versions) |
| 43 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 44 | + curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64 |
| 45 | + elif [ "$RUNNER_OS" == "macOS" ]; then |
| 46 | + curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64 |
| 47 | + fi |
| 48 | + chmod +x /tmp/bazelisk |
| 49 | + sudo mv /tmp/bazelisk /usr/local/bin/bazel |
| 50 | + echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV |
| 51 | + bazel --version |
| 52 | +
|
| 53 | + - name: Install build tooling |
| 54 | + shell: bash -l {0} |
| 55 | + run: | |
| 56 | + python -m pip install --upgrade pip build wheel "setuptools<69.3" |
| 57 | +
|
| 58 | + - name: Build the package |
| 59 | + shell: bash -l {0} |
| 60 | + run: | |
| 61 | + python -m build --wheel --no-isolation |
| 62 | +
|
| 63 | + - name: Repair wheel for manylinux |
| 64 | + if: runner.os == 'Linux' |
| 65 | + shell: bash -l {0} |
| 66 | + run: | |
| 67 | + python -m pip install auditwheel |
| 68 | + WHEEL_PATH="$(ls dist/*.whl)" |
| 69 | + auditwheel repair --plat auto -w dist "${WHEEL_PATH}" |
| 70 | + rm "${WHEEL_PATH}" |
| 71 | +
|
| 72 | + - name: Upload wheel artifact |
| 73 | + |
| 74 | + with: |
| 75 | + name: ml-metadata-wheel-${{ matrix.os }}-py${{ matrix.python-version }} |
| 76 | + path: dist/*.whl |
| 77 | + |
| 78 | + upload_to_pypi: |
| 79 | + name: Upload to PyPI |
| 80 | + runs-on: ubuntu-latest |
| 81 | + if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch') |
| 82 | + needs: [build] |
| 83 | + environment: |
| 84 | + name: pypi |
| 85 | + url: https://pypi.org/p/ml-metadata/ |
| 86 | + permissions: |
| 87 | + id-token: write |
| 88 | + steps: |
| 89 | + - name: Retrieve wheels |
| 90 | + |
| 91 | + with: |
| 92 | + merge-multiple: true |
| 93 | + path: wheels |
| 94 | + |
| 95 | + - name: List the build artifacts |
| 96 | + run: | |
| 97 | + ls -lAs wheels/ |
| 98 | +
|
| 99 | + - name: Upload to PyPI |
| 100 | + uses: pypa/gh-action-pypi-publish@release/v1.9 |
| 101 | + with: |
| 102 | + packages_dir: wheels/ |
0 commit comments