Fix pip module tests (#423) #23
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 | |
| release: | |
| types: [published] | |
| jobs: | |
| build-and-publish: | |
| name: Build and release 🐍 📦 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v2 | |
| with: | |
| python-version: 3.8 | |
| - run: python -m pip install build --user | |
| - run: python -m build --sdist --wheel --outdir dist/ . | |
| - name: Test wheel contents before upload | |
| run: | | |
| pip install 'mhkit[all]' --no-index --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 | |
| if: github.event_name != 'release' && 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 }} |