From ffcfe40a08962a98396122203f4c9c96be73e210 Mon Sep 17 00:00:00 2001 From: Ben Frederickson Date: Wed, 6 Apr 2022 14:40:31 -0700 Subject: [PATCH] Automate pushing package to pypi After tagging a release, this will automatically push the package the pypi as well as create the github release attaching the same sdist package to the release attachments. --- .github/workflows/cpu-ci.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/cpu-ci.yml b/.github/workflows/cpu-ci.yml index 826c56f5b59..c0a2288e638 100644 --- a/.github/workflows/cpu-ci.yml +++ b/.github/workflows/cpu-ci.yml @@ -1,8 +1,11 @@ name: CPU CI on: + workflow_dispatch: push: branches: [ main ] + tags: + - v* pull_request: branches: [ main ] @@ -56,6 +59,14 @@ jobs: - name: Run unittests run: | python -m pytest -rxs tests/unit/ + - name: Generate package for pypi + run: | + python setup.py sdist + - name: Upload artifacts to github + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist # Build docs, treat warnings as errors - name: Building docs run: | @@ -78,3 +89,28 @@ jobs: with: name: pr path: pr/ + + release: + name: Release + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + needs: [build] + steps: + - uses: actions/download-artifact@v2 + with: + name: dist + - name: Create GitHub Release + uses: fnkr/github-action-ghr@v1.3 + env: + GHR_PATH: . + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Push to PyPi + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + pip install --upgrade wheel pip setuptools twine + twine upload *