diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a04b05d..dc5caa1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,6 +1,19 @@ name: CI -"on": [push] +"on": + push: + branches-ignore: + # These should always correspond to pull requests, so ignore them for + # the push trigger and let them be triggered by the pull_request + # trigger, avoiding running the workflow twice. This is a minor + # optimization so there's no need to ensure this is comprehensive. + - "dependabot/**" + - "renovate/**" + - "tickets/**" + - "u/**" + tags: + - "*" + pull_request: {} jobs: test: @@ -38,3 +51,29 @@ jobs: - name: Run tox run: tox -e py,coverage-report,typing + pypi: + runs-on: ubuntu-latest + needs: [test] + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: "pip" + cache-dependency-path: "setup.cfg" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: "__token__" + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel --universal + twine upload dist/*