diff --git a/.github/workflows/release_pypi.yaml b/.github/workflows/release_pypi.yaml index 37091a8..f2fae7a 100644 --- a/.github/workflows/release_pypi.yaml +++ b/.github/workflows/release_pypi.yaml @@ -1,32 +1,51 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# From: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Upload Python Package +name: Release to Pypi +# Run on a published release and push to Pypi on: release: types: [published] jobs: - deploy: + build_dist: + name: Build source distribution runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 + + - uses: actions/setup-python@v2 + name: Install Python with: - python-version: '3.9' + python-version: "3.9" + - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + python3 -m pip install --upgrade pip wheel + python3 -m pip install . + + - name: Build dist + run: python setup.py sdist --formats=gztar + + - name: Build wheel + run: python3 setup.py bdist_wheel + + - uses: actions/upload-artifact@v2 with: - user: __token__ - password: ${{ secrets.PYPI_SECRET }} + path: dist/*.tar.gz + + pypi-publish: + needs: [build_dist] + name: upload release to PyPI + runs-on: ubuntu-latest + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + if: github.event_name == 'release' && github.event.action == 'published' + steps: + # retrieve your distributions here + - uses: actions/download-artifact@v2 + with: + name: artifact + path: dist + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1