Merge pull request #66 from Bayes-Works/bugfix/docs #213
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish to PyPI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-publish: | |
| name: Build and Publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libopenmpi-dev | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build twine | |
| - name: Clean build environment | |
| run: rm -rf dist/ build/ *.egg-info | |
| - name: Build package | |
| run: python -m build | |
| - name: Upload to PyPI | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| twine upload --verbose --repository pypi dist/* | |
| unit-test: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install OpenMPI runtime (APT) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libopenmpi-dev build-essential libnccl-dev | |
| - name: Set up Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-activate-base: true | |
| auto-update-conda: true | |
| channels: conda-forge | |
| python-version: "3.10" | |
| - name: Create test_env | |
| shell: bash -l {0} | |
| run: conda create -y -n test_env python=3.10 -c conda-forge | |
| - name: Install Python deps | |
| shell: bash -l {0} | |
| run: | | |
| conda activate test_env | |
| python -V | |
| pip -V | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: Run unit tests | |
| shell: bash -l {0} | |
| run: | | |
| conda activate test_env | |
| pytest test |