Use hatch for publishing #349
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: Main | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| test: | |
| name: Run tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python_version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
| install_extras: ['tests', 'plotting,fancy_progressbar,tests', 'plotting,bloch_sphere_visualization,fancy_progressbar,doc,tests'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python_version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python_version }} | |
| cache: pip | |
| check-latest: true | |
| - name: Install | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install hatch .[${{ matrix.install_extras }}] | |
| - name: Test with pytest | |
| run: | | |
| python -m pytest | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| name: ${{ matrix.python }} - ${{ matrix.install_extras }} | |
| env_vars: OS,PYTHON | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} # required | |
| verbose: true | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| name: ${{ matrix.python }} - ${{ matrix.install_extras }} | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| release: | |
| name: Publish to PyPi | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| cache: pip | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install hatch | |
| - name: Build package | |
| run: | | |
| python -m hatch build | |
| - name: Publish package | |
| env: | |
| HATCH_INDEX_USER: __token__ | |
| HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| python -m hatch publish |