Fix wheel build test #26
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
| # Builds mhkit and publishes to testpypi.org on every commit to main. On tagged commits, also publishes to pypi.org. | |
| # https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
| name: Build and release 🐍 📦 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| release: | |
| types: [published] | |
| jobs: | |
| build-and-publish: | |
| name: Build and release 🐍 📦 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - run: python -m pip install build --user | |
| - run: python -m build --sdist --wheel --outdir dist/ . | |
| - name: Test wheel contents before upload | |
| run: | | |
| # Install the built wheel from dist/ to verify it was packaged correctly before upload | |
| # --find-links dist/ tells pip to look in dist/ directory first and prefer the wheel | |
| # Dependencies (numpy, pandas, etc.) are fetched from PyPI as normal | |
| # This verifies the wheel contains all necessary files and can be installed successfully | |
| pip install 'mhkit[all]' --find-links dist/ | |
| python -c "from mhkit import wave, river, tidal, dolfyn, power, loads, mooring, acoustics, qc, utils; print('All modules imported successfully')" | |
| - name: Upload to Test PyPI (commits to main only) | |
| if: github.event_name == 'push' && github.repository_owner == 'MHKiT-Software' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
| repository-url: https://test.pypi.org/legacy/ | |
| skip-existing: true | |
| - name: Upload to PyPI (tagged release only) | |
| if: | |
| github.repository_owner == 'MHKiT-Software' && github.event_name == 'release' && | |
| github.event.action == 'published' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} |