|
| 1 | +# (C) Copyright 2024- ECMWF. |
| 2 | +# |
| 3 | +# This software is licensed under the terms of the Apache Licence Version 2.0 |
| 4 | +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 5 | +# In applying this licence, ECMWF does not waive the privileges and immunities |
| 6 | +# granted to it by virtue of its status as an intergovernmental organisation |
| 7 | +# nor does it submit to any jurisdiction. |
| 8 | + |
| 9 | + |
| 10 | +name: Build Python Wheel for MacOS |
| 11 | + |
| 12 | +on: |
| 13 | + # Trigger the workflow manually |
| 14 | + workflow_dispatch: ~ |
| 15 | + |
| 16 | + # Allow to be called from another workflow |
| 17 | + workflow_call: ~ |
| 18 | + |
| 19 | + # TODO automation trigger |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: Build macos wheel |
| 24 | + # TODO enable after all tested |
| 25 | + # strategy: |
| 26 | + # matrix: |
| 27 | + # arch_type: [ARM64, X64] |
| 28 | + # runs-on: [self-hosted, macOS, "${{ matrix.arch_type }}"] |
| 29 | + runs-on: [self-hosted, macOS, ARM64 ] |
| 30 | + steps: |
| 31 | + # TODO convert this to be matrix-friendly for python versions. Note it's a bit tricky since |
| 32 | + # we'd ideally not reexecute the compile step multiple times, but it |
| 33 | + # (non-essentially) depends on a matrix-based step |
| 34 | + # NOTE we dont use action checkout because it doesnt cleanup after itself correctly |
| 35 | + - run: | |
| 36 | + if [ -z "$(which uv)" ] ; then curl -LsSf https://astral.sh/uv/install.sh | sh ; fi |
| 37 | + rm -rf ecbuild wheelmaker |
| 38 | + git clone --depth=1 https://github.com/ecmwf/ecbuild ecbuild |
| 39 | + # git clone --depth=1 --branch="wheelmaker" https://github.com/ecmwf/ci-utils wheelmaker # TODO use token here to get rid of the checkout action below |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + repository: ecmwf/ci-utils |
| 43 | + ref: develop |
| 44 | + path: ci-utils |
| 45 | + token: ${{ secrets.GH_REPO_READ_TOKEN }} |
| 46 | + - run: rm -rf proj && git clone --depth=1 --branch="${GITHUB_REF#refs/heads/}" https://github.com/$GITHUB_REPOSITORY proj |
| 47 | + - run: | |
| 48 | + cd proj && $GITHUB_WORKSPACE/ci-utils/wheelmaker/buildscripts/prepare_deps.sh ./python_wrapper/buildconfig 3.11 |
| 49 | + - run: | |
| 50 | + cd proj |
| 51 | + if [[ -f ./python_wrapper/pre-compile.sh ]] ; then ./python_wrapper/pre-compile.sh ; fi |
| 52 | + PATH="$PATH:$GITHUB_WORKSPACE/ecbuild/bin/" $GITHUB_WORKSPACE/ci-utils/wheelmaker/buildscripts/compile.sh ./python_wrapper/buildconfig |
| 53 | + - run: | |
| 54 | + cd proj |
| 55 | + rm -rf /tmp/buildvenv && uv python install python3.11 && uv venv --python python3.11 /tmp/buildvenv && source /tmp/buildvenv/bin/activate && uv pip install build twine |
| 56 | + PYTHONPATH=$GITHUB_WORKSPACE/ci-utils/wheelmaker/buildscripts $GITHUB_WORKSPACE/ci-utils/wheelmaker/buildscripts/wheel-linux.sh ./python_wrapper/buildconfig 3.11 |
| 57 | + if [[ -f ./python_wrapper/post-build.sh ]] ; then ./python_wrapper/post-build.sh ; fi |
| 58 | + $GITHUB_WORKSPACE/ci-utils/wheelmaker/buildscripts/test-wheel.sh ./python_wrapper/buildconfig 3.11 |
| 59 | + $GITHUB_WORKSPACE/ci-utils/wheelmaker/buildscripts/upload-pypi.sh ./python_wrapper/buildconfig |
| 60 | + env: |
| 61 | + TWINE_USERNAME: __token__ |
| 62 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 63 | + # NOTE temporary thing until all the mess gets cleared |
| 64 | + - run: rm -rf ./* ./.git ./.github |
0 commit comments