name: Publish Python Package to PyPI on: release: types: [published] jobs: pypi-publish: name: Upload release to PyPI runs-on: ubuntu-latest environment: name: pypi url: https://pypi.org/p/librespot-spotizerr # Optional: Link to your PyPI project permissions: id-token: write # IMPORTANT: mandatory for trusted publishing steps: - name: Checkout repository uses: actions/checkout@v4 - name: Get version from tag id: get_version run: | # Strip 'v' prefix if present VERSION_TAG="${GITHUB_REF_NAME#v}" echo "VERSION=$VERSION_TAG" >> $GITHUB_OUTPUT echo "Using version for build: $VERSION_TAG" - name: Update version in setup.py run: | VERSION_TAG="${{ steps.get_version.outputs.VERSION }}" sed -i "s/\\\\(version *= *[\\\\\\"']\\\\)[^\\\\\\"']*\([\\\\\\"']\\\\)/\\\\1$VERSION_TAG\\\\2/" setup.py echo "Updated setup.py to version $VERSION_TAG for build:" cat setup.py - name: Update version in librespot/__init__.py run: | VERSION_TAG="${{ steps.get_version.outputs.VERSION }}" sed -i "s/\\\\(version_name *= *[\\\\\\"']\\\\)[^\\\\\\"']*\([\\\\\\"']\\\\)/\\\\1$VERSION_TAG\\\\2/" librespot/__init__.py echo "Updated librespot/__init__.py to version $VERSION_TAG for build:" cat librespot/__init__.py - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.x" - name: Install build dependencies run: | python -m pip install --upgrade pip pip install build - name: Build package run: python -m build - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 # No need for user/password with trusted publishing # If not using trusted publishing, you would uncomment and use: # with: # user: __token__ # password: ${{ secrets.PYPI_API_TOKEN }}