This commit is contained in:
cool.gitter.not.me.again.duh
2025-05-31 16:24:08 -06:00
parent 670f44b032
commit 13a3bab5ff
2 changed files with 63 additions and 1 deletions

62
.github/workflows/publish-to-pypi.yml vendored Normal file
View File

@@ -0,0 +1,62 @@
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 }}

View File

@@ -1,6 +1,6 @@
import setuptools
setuptools.setup(name="librespot",
setuptools.setup(name="librespot-spotizerr",
version="0.1.0",
description="Spotizerr's python librespot implementation",
long_description=open("README.md").read(),