diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..3160ed2 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,48 @@ +name: Publish Python package to PyPI - JianboHIT + +on: + push: + tags: + - 'v*' + +jobs: + build-and-publish: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python 3.8 + uses: actions/setup-python@v5 + with: + python-version: '3.8' + + - name: Install build and twine + run: | + python -m pip install --upgrade pip + pip install setuptools build twine + + - name: Install package dependencies + run: | + pip install -e .[full] + + - name: Run tests + run: | + python3 -m unittest discover -s tests -v + + - name: Build package + run: | + python -m build + + - name: Check package with twine + run: | + twine check dist/* + + - name: Publish to PyPI + if: success() + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.JIANBOHIT_PYPI_API_TOKEN }} + repository-url: https://upload.pypi.org/legacy/ +