diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 579ce3f..646c8e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,7 @@ on: permissions: contents: write packages: write + id-token: write # Required for PyPI trusted publishing env: PYTHON_VERSION: '3.10' @@ -91,19 +92,41 @@ jobs: --- See [CHANGELOG](https://github.com/jatinkrmalik/vocalinux/releases) for detailed changes. - # Optional: publish to PyPI when ready - # publish-pypi: - # name: Publish to PyPI - # needs: build-and-release - # runs-on: ubuntu-latest - # if: ${{ !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') }} - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: ${{ env.PYTHON_VERSION }} - # - run: pip install build twine - # - run: python -m build - # - uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # password: ${{ secrets.PYPI_API_TOKEN }} + publish-pypi: + name: Publish to PyPI + needs: build-and-release + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/vocalinux/ + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: 'pip' + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + + - name: Build package + run: | + python -m build + echo "Built packages:" + ls -la dist/ + + - name: Verify package + run: | + twine check dist/* + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + twine upload dist/* --skip-existing