|
| 1 | +name: Packaging |
| 2 | + |
| 3 | +on: |
| 4 | + - push |
| 5 | + |
| 6 | +jobs: |
| 7 | + format: |
| 8 | + name: Check formatting |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + |
| 13 | + - uses: actions/setup-python@v5 |
| 14 | + with: |
| 15 | + python-version: "3.12" |
| 16 | + |
| 17 | + - name: Install tox |
| 18 | + run: python -m pip install tox |
| 19 | + |
| 20 | + - name: Run black |
| 21 | + run: tox -e format |
| 22 | + |
| 23 | + lint: |
| 24 | + name: Lint |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: "3.12" |
| 32 | + |
| 33 | + - name: Install tox |
| 34 | + run: python -m pip install tox |
| 35 | + |
| 36 | + - name: Run flake8 |
| 37 | + run: tox -e lint |
| 38 | + |
| 39 | + typecheck: |
| 40 | + name: Type check |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - uses: actions/setup-python@v5 |
| 46 | + with: |
| 47 | + python-version: "3.12" |
| 48 | + |
| 49 | + - name: Install tox |
| 50 | + run: python -m pip install tox |
| 51 | + |
| 52 | + - name: Run mypy |
| 53 | + run: python -m tox -e typecheck |
| 54 | + |
| 55 | + test: |
| 56 | + name: Test |
| 57 | + runs-on: ubuntu-latest |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + python: |
| 61 | + - version: "3.13" |
| 62 | + toxenv: "py313" |
| 63 | + - version: "3.12" |
| 64 | + toxenv: "py312" |
| 65 | + - version: "3.11" |
| 66 | + toxenv: "py311" |
| 67 | + - version: "3.10" |
| 68 | + toxenv: "py310" |
| 69 | + - version: "3.9" |
| 70 | + toxenv: "py39" |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v4 |
| 73 | + |
| 74 | + - uses: actions/setup-python@v5 |
| 75 | + with: |
| 76 | + python-version: ${{ matrix.python.version }} |
| 77 | + |
| 78 | + - name: Install tox |
| 79 | + run: python -m pip install tox |
| 80 | + |
| 81 | + - name: Run pytest |
| 82 | + run: tox -e ${{ matrix.python.toxenv }} |
| 83 | + |
| 84 | + build_source_dist: |
| 85 | + name: Build source distribution |
| 86 | + runs-on: ubuntu-latest |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v4 |
| 89 | + |
| 90 | + - uses: actions/setup-python@v5 |
| 91 | + with: |
| 92 | + python-version: "3.12" |
| 93 | + |
| 94 | + - name: Install build |
| 95 | + run: python -m pip install build |
| 96 | + |
| 97 | + - name: Run build |
| 98 | + run: python -m build --sdist |
| 99 | + |
| 100 | + - uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + path: dist/*.tar.gz |
| 103 | + |
| 104 | + publish: |
| 105 | + needs: [format, lint, typecheck, test] |
| 106 | + if: startsWith(github.ref, 'refs/tags') |
| 107 | + runs-on: ubuntu-latest |
| 108 | + environment: release |
| 109 | + permissions: |
| 110 | + id-token: write |
| 111 | + contents: write |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v4 |
| 114 | + |
| 115 | + - name: Set up Python |
| 116 | + uses: actions/setup-python@v5 |
| 117 | + with: |
| 118 | + python-version: 3.9 |
| 119 | + |
| 120 | + - name: Install pypa/build |
| 121 | + run: python -m pip install build |
| 122 | + |
| 123 | + - name: Build distribution |
| 124 | + run: python -m build --outdir dist/ |
| 125 | + |
| 126 | + - name: Publish distribution to Test PyPI |
| 127 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 128 | + with: |
| 129 | + repository_url: https://test.pypi.org/legacy/ |
| 130 | + |
| 131 | + - name: Publish distribution to PyPI |
| 132 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 133 | + |
| 134 | + - name: Publish distribution to GitHub release |
| 135 | + uses: softprops/action-gh-release@v2 |
| 136 | + with: |
| 137 | + files: | |
| 138 | + dist/django_webmention-*.whl |
| 139 | + dist/django_webmention-*.tar.gz |
| 140 | + env: |
| 141 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments