name: Publish Python Package to PyPI on: release: types: [published] jobs: build-and-publish: name: Build and publish Python package to PyPI runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v3 with: python-version: "3.x" - name: Update version in files run: | TAG_VERSION="${{ github.ref_name }}" # Remove 'v' prefix if it exists VERSION="${TAG_VERSION#v}" echo "Using version: $VERSION" # Update pyproject.toml sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml # Update setup.py sed -i "s/^\s*version = .*/ version = \"${VERSION}\",/" setup.py echo "pyproject.toml version:" grep "^version = " pyproject.toml echo "setup.py version:" grep "^\s*version = " setup.py - name: Install pypa/build run: >- python -m pip install build --user - name: Build a binary wheel and a source tarball run: >- python -m build --sdist --wheel --outdir dist/ . - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} # You may want to publish to a test PyPI repository first # repository_url: https://test.pypi.org/legacy/ # package_name: deezspot-spotizerr # Ensure this matches your package name if needed explicitly