Build and deploy MHCXGraph #89
Workflow file for this run
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 deploy MHCXGraph | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build sdist and wheel | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - name: Install PyPA's build | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install --upgrade build | |
| - name: Build distribution archives | |
| run: | | |
| python -m build --wheel --sdist . | |
| - name: Extract package version | |
| id: get_version | |
| run: | | |
| VERSION=$(ls dist/*.tar.gz | sed -E 's/.*mhcxgraph-([0-9]+(\.[0-9]+)*).*/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected version: $VERSION" | |
| - name: Upload distribution archives | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: artifacts | |
| path: | | |
| ./dist/*.whl | |
| ./dist/*.tar.gz | |
| test-on-different-os: | |
| name: Test on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| needs: [build] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: artifacts | |
| path: ./dist | |
| - name: Test sdist on ${{ matrix.os }} | |
| run: | | |
| python -m pip install --upgrade pip pytest | |
| python -m pip install dist/mhcxgraph-${{ needs.build.outputs.version }}.tar.gz | |
| python -c "import MHCXGraph; print(MHCXGraph.__version__)" | |
| - name: Test wheel on ${{ matrix.os }} | |
| run: | | |
| python -m pip install --upgrade pip pytest | |
| python -m pip install dist/mhcxgraph-${{ needs.build.outputs.version }}-py3-none-any.whl | |
| python -c "import MHCXGraph; print(MHCXGraph.__version__)" | |
| pypi-publish: | |
| name: Upload release to PyPI | |
| runs-on: ubuntu-latest | |
| needs: [test-on-different-os] | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/MHCXGraph | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: artifacts | |
| path: ./dist | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} |