|
| 1 | +name: build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: ["dev"] |
| 5 | + tags: ["*"] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + tests: |
| 10 | + name: ${{ matrix.name }} |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - { name: "3.8", python: "3.8", tox: py38 } |
| 17 | + - { name: "3.12", python: "3.12", tox: py312 } |
| 18 | + - { name: "lowest", python: "3.8", tox: py38-lowest } |
| 19 | + steps: |
| 20 | + |
| 21 | + - uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python }} |
| 24 | + - name: Download nltk data |
| 25 | + run: wget https://s3.amazonaws.com/textblob/nltk_data-0.11.0.tar.gz |
| 26 | + - name: Extract nltk data |
| 27 | + run: tar -xzvf nltk_data-0.11.0.tar.gz -C ~ |
| 28 | + - run: python -m pip install tox |
| 29 | + - run: python -m tox -e${{ matrix.tox }} |
| 30 | + build: |
| 31 | + name: Build package |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + - uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: "3.11" |
| 38 | + - name: Install pypa/build |
| 39 | + run: python -m pip install build |
| 40 | + - name: Build a binary wheel and a source tarball |
| 41 | + run: python -m build |
| 42 | + - name: Install twine |
| 43 | + run: python -m pip install twine |
| 44 | + - name: Check build |
| 45 | + run: python -m twine check --strict dist/* |
| 46 | + - name: Store the distribution packages |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: python-package-distributions |
| 50 | + path: dist/ |
| 51 | + # this duplicates pre-commit.ci, so only run it on tags |
| 52 | + # it guarantees that linting is passing prior to a release |
| 53 | + lint-pre-release: |
| 54 | + if: startsWith(github.ref, 'refs/tags') |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + |
| 58 | + - uses: actions/setup-python@v5 |
| 59 | + with: |
| 60 | + python-version: "3.11" |
| 61 | + - run: python -m pip install tox |
| 62 | + - run: python -m tox -e lint |
| 63 | + publish-to-pypi: |
| 64 | + name: PyPI release |
| 65 | + if: startsWith(github.ref, 'refs/tags/') |
| 66 | + needs: [build, tests, lint-pre-release] |
| 67 | + runs-on: ubuntu-latest |
| 68 | + environment: |
| 69 | + name: pypi |
| 70 | + url: https://pypi.org/p/textblob |
| 71 | + permissions: |
| 72 | + id-token: write |
| 73 | + steps: |
| 74 | + - name: Download all the dists |
| 75 | + uses: actions/download-artifact@v4 |
| 76 | + with: |
| 77 | + name: python-package-distributions |
| 78 | + path: dist/ |
| 79 | + - name: Publish distribution to PyPI |
| 80 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments