diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0bdaf02 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,119 @@ +name: publish +on: + workflow_dispatch: # Allow running the workflow manually from the GitHub UI + push: + branches: + - 'master' # Run the workflow when pushing to the main branch + tags: + - '*' + pull_request: + branches: + - '*' # Run the workflow for all pull requests + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: python3 -m pip install build --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-testpypi: + name: Publish Python distribution to TestPyPI + needs: + - build + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/steelseries-sonar-py + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + publish-to-pypi: + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/steelseries-sonar-py + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: >- + Sign the Python distribution with Sigstore + and upload them to GitHub Release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5754f4b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +requires = ["setuptools>=60", "setuptools-scm>=8.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b03abb7 --- /dev/null +++ b/setup.py @@ -0,0 +1,50 @@ +import setuptools + +with open('README.md', 'r', encoding='utf-8') as fh: + long_description = fh.read() + +setuptools.setup( + name='steelseries-sonar-py', + author='Mark7888', + author_email='l.mark7888@gmail.com', + description='Simple Python wrapper for the SteelSeries Sonar API', + keywords='steelseries, sonar, volume, control, sonar-api', + long_description=long_description, + long_description_content_type='text/markdown', + url='https://github.com/Mark7888/steelseries-sonar-py', + project_urls={ + 'Documentation': 'https://github.com/Mark7888/steelseries-sonar-py/blob/master/README.md', + 'Bug Reports': 'https://github.com/Mark7888/steelseries-sonar-py/issues', + 'Source Code': 'https://github.com/Mark7888/steelseries-sonar-py', + }, + package_dir={'': 'src'}, + packages=setuptools.find_packages(where='src'), + install_requires=[ + 'requests >= 2.31.0', + ], + classifiers=[ + # see https://pypi.org/classifiers/ + 'Development Status :: 5 - Production/Stable', + + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Build Tools', + + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.1', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3 :: Only', + 'License :: OSI Approved :: MIT License', + 'Operating System :: Windows', + ], + python_requires='>=3', +) diff --git a/src/steelseries_sonar_py/__init__.py b/src/steelseries_sonar_py/__init__.py new file mode 100644 index 0000000..959787a --- /dev/null +++ b/src/steelseries_sonar_py/__init__.py @@ -0,0 +1 @@ +from .sonar import * diff --git a/sonar.py b/src/steelseries_sonar_py/sonar.py similarity index 100% rename from sonar.py rename to src/steelseries_sonar_py/sonar.py