Repository navigation
Build, test, and publish #16
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, test, and publish | |
| on: | |
| pull_request: | |
| push: | |
| tags: ["v*"] | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| test_version: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Build sdist and wheel | |
| run: | | |
| python -m pip install -U pip build | |
| python -m build --sdist --wheel --outdir dist | |
| - name: Install wheel and run tests | |
| run: | | |
| python -m pip install -U pytest pytest-cov pytest-benchmark pyhdf | |
| python -m pip install dist/*.whl | |
| pytest | |
| test_build_target: | |
| needs: test_version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: .python-version | |
| - name: Build sdist + wheel | |
| run: | | |
| python -m pip install -U pip build | |
| python -m build --sdist --wheel --outdir dist | |
| - name: Install wheel and run tests | |
| run: | | |
| python -m pip install -U pytest pytest-cov pytest-benchmark pyhdf | |
| python -m pip install dist/*.whl | |
| pytest | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/* | |
| retention-days: 7 | |
| publish: | |
| needs: test_build_target | |
| runs-on: ubuntu-latest | |
| #if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release' | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist | |
| - name: Upload to GitHub releases | |
| uses: softprops/action-gh-release@v2.4.1 | |
| with: | |
| draft: false | |
| generate_release_notes: false | |
| files: | | |
| dist/* |