publish-test-pypi #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: publish-test-pypi | |
| on: | |
| push: | |
| branches: [ main ] # Trigger 1: Code changes (Merge) | |
| release: | |
| types: [ published ] # Trigger 2: You click "Draft a new release" on GitHub | |
| workflow_dispatch: | |
| jobs: | |
| style-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout-out Repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '>= 3.10' | |
| - name: Install hatch | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install hatch | |
| - name: Run Ruff Linting | |
| run: hatch run lint:check | |
| unit-test-pytest: | |
| needs: style-check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check-out repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '>= 3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e .[tests] | |
| - name: Run tests with coverage | |
| run: | | |
| pytest --cov --cov-report=xml --cov-branch | |
| pypi-test: | |
| needs: unit-test-pytest | |
| runs-on: ubuntu-latest | |
| # Added if so publishing only happens on release | |
| if: github.event_name == 'release' | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Check-out repository | |
| uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 # Included for dynamic version updating | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '>= 3.10' | |
| - name: Install hatch | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e .[dev] | |
| - name: Build package | |
| run: hatch build | |
| - name: Publish to Test PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| skip-existing: true # prevents failure upon accident re-runs |