|
| 1 | +name: Publish to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + validate-release: |
| 9 | + name: Validate Release Across Python Versions |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + python-version: ["3.9", "3.10", "3.11", "3.12"] |
| 14 | + fail-fast: false |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + ref: ${{ github.event.release.tag_name }} |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + |
| 27 | + - name: Update pip |
| 28 | + run: python -m pip install --upgrade pip |
| 29 | + |
| 30 | + - name: Install wheel and build tools |
| 31 | + run: python -m pip install --upgrade wheel build |
| 32 | + |
| 33 | + - name: Install project dependencies |
| 34 | + run: | |
| 35 | + pip install -r ci/requirements.txt |
| 36 | + pip install . |
| 37 | +
|
| 38 | + - name: Run tests |
| 39 | + run: pytest tests --cov solt --cov-report term-missing -v |
| 40 | + |
| 41 | + - name: Check code formatting |
| 42 | + run: black --config=black.toml --check . |
| 43 | + |
| 44 | + - name: Run flake8 linter |
| 45 | + run: flake8 |
| 46 | + |
| 47 | + build-and-publish: |
| 48 | + name: Build and Publish to PyPI |
| 49 | + runs-on: ubuntu-latest |
| 50 | + needs: validate-release |
| 51 | + environment: |
| 52 | + name: pypi |
| 53 | + url: https://pypi.org/project/solt/ |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout code |
| 57 | + uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + ref: ${{ github.event.release.tag_name }} |
| 60 | + |
| 61 | + - name: Set up Python |
| 62 | + uses: actions/setup-python@v5 |
| 63 | + with: |
| 64 | + python-version: "3.11" |
| 65 | + |
| 66 | + - name: Install build tools |
| 67 | + run: | |
| 68 | + python -m pip install --upgrade pip |
| 69 | + python -m pip install --upgrade wheel build twine |
| 70 | +
|
| 71 | + - name: Build distributions |
| 72 | + run: | |
| 73 | + python -m build |
| 74 | +
|
| 75 | + - name: Validate built packages with twine |
| 76 | + run: | |
| 77 | + twine check dist/* |
| 78 | +
|
| 79 | + - name: Publish to PyPI |
| 80 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 81 | + with: |
| 82 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 83 | + packages-dir: dist/ |
| 84 | + verbose: true |
0 commit comments