|
| 1 | +name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI |
| 2 | + |
| 3 | +on: push |
| 4 | + |
| 5 | +jobs: |
| 6 | + tests: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + strategy: |
| 9 | + fail-fast: false |
| 10 | + matrix: |
| 11 | + include: |
| 12 | + - django-version: "2.2.0" |
| 13 | + python-version: "3.8" |
| 14 | + - django-version: "3.2.0" |
| 15 | + python-version: "3.8" |
| 16 | + - django-version: "4.0.0" |
| 17 | + python-version: "3.8" |
| 18 | + - django-version: "2.2.0" |
| 19 | + python-version: "3.10" |
| 20 | + - django-version: "3.2.0" |
| 21 | + python-version: "3.10" |
| 22 | + - django-version: "4.0.0" |
| 23 | + python-version: "3.10" |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + - name: Set up Python ${{ matrix.python-version }} |
| 27 | + uses: actions/setup-python@v2 |
| 28 | + with: |
| 29 | + python-version: ${{ matrix.python-version }} |
| 30 | + |
| 31 | + - name: Upgrade pip version |
| 32 | + run: | |
| 33 | + python -m pip install -U pip |
| 34 | +
|
| 35 | + - name: Install test requirements/linters |
| 36 | + run: pip install -r tests/requirements.txt |
| 37 | + |
| 38 | + - name: Upgrade django version |
| 39 | + run: | |
| 40 | + python -m pip install "Django~=${{ matrix.django-version }}" |
| 41 | +
|
| 42 | + - name: Run pre-commit |
| 43 | + run: pre-commit run --all-files |
| 44 | + |
| 45 | + |
| 46 | + build-n-publish: |
| 47 | + needs: tests |
| 48 | + name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v2 |
| 52 | + - name: Set up Python ${{ matrix.python-version }} |
| 53 | + uses: actions/setup-python@v2 |
| 54 | + - name: Install pypa/build |
| 55 | + run: >- |
| 56 | + python -m |
| 57 | + pip install |
| 58 | + build |
| 59 | + --user |
| 60 | + - name: Build a binary wheel and a source tarball |
| 61 | + run: >- |
| 62 | + python -m |
| 63 | + build |
| 64 | + --sdist |
| 65 | + --wheel |
| 66 | + --outdir dist/ |
| 67 | + - name: Publish distribution 📦 to Test PyPI |
| 68 | + uses: pypa/gh-action-pypi-publish@master |
| 69 | + continue-on-error: true |
| 70 | + with: |
| 71 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 72 | + repository_url: https://test.pypi.org/legacy/ |
| 73 | + - name: Publish distribution 📦 to PyPI |
| 74 | + if: startsWith(github.ref, 'refs/tags') |
| 75 | + uses: pypa/gh-action-pypi-publish@master |
| 76 | + with: |
| 77 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments