diff --git a/.github/workflows/release_pypi_github.yaml b/.github/workflows/release_pypi_github.yaml new file mode 100644 index 0000000..4850411 --- /dev/null +++ b/.github/workflows/release_pypi_github.yaml @@ -0,0 +1,64 @@ +name: Publish to PyPI and release to GitHub on tag + +on: + push: + branches: + - main + tags: + - "*" + +jobs: + build-n-publish: + name: Build and publish to PyPI + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@v4.1.1 + + - name: Set up Python + uses: actions/setup-python@v5.0.0 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine bumpver build + + - name: Build source and wheel distributions + run: | + python -m build + twine check dist/* + + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Create GitHub Release + id: create_release + uses: ncipollo/release-action@v1.14.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + draft: false + prerelease: false + + - name: Get Asset name + run: | + export PKG=$(ls dist/ | grep tar) + set -- $PKG + echo "name=$1" >> $GITHUB_ENV + + - name: Upload Release Asset (sdist) to GitHub + id: upload-release-asset + uses: tanyagray/action-upload-release-asset@v1.1.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/${{ env.name }} + asset_name: ${{ env.name }} + asset_content_type: application/zip