diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 859f033..afe8a2e 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -1,7 +1,7 @@ --- name: pre-commit -on: +"on": pull_request: push: branches: [main] @@ -10,7 +10,7 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.9" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0f3b137..ad12d26 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,15 +1,19 @@ --- name: Upload Python Package -on: +"on": release: types: [created] jobs: publish: runs-on: ubuntu-latest + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: @@ -18,10 +22,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements-dev.txt - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python -m build - twine upload dist/* + - name: Build + run: python -m build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2bc9aa..09d0511 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,18 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - id: requirements-txt-fixer - - repo: https://github.com/psf/black - rev: 22.3.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.11.0 hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort diff --git a/pyproject.toml b/pyproject.toml index e7c4074..e92b7fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,42 @@ +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "co2mini" +description = "Monitor CO2 levels with Prometheus and/or HomeKit" +readme = "README.md" +authors = [{ email = "jeremy@jerr.dev" }, { name = "Jeremy Mayeres" }] +requires-python = ">=3.9" +keywords = [ + "co2", + "co2mini", + "temperature", + "humidity", + "sensors", + "prometheus", + "homekit", +] +license = { file = "LICENSE" } +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Development Status :: 3 - Alpha", +] +dependencies = ["prometheus_client"] +dynamic = ["version"] + +[project.urls] +repository = "https://github.com/jerr0328/co2-mini" + +[project.optional-dependencies] +homekit = ["HAP-python"] + +[project.scripts] +co2mini = "co2mini.main:main" + [tool.isort] profile = "black" -[build-system] -requires = ["setuptools>=45", "wheel"] -build-backend = "setuptools.build_meta" +[tool.setuptools_scm] diff --git a/requirements-dev.txt b/requirements-dev.txt index 6b90ee6..ce84570 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,5 +5,5 @@ flake8 isort pre-commit setuptools -twine +setuptools-scm wheel diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2d08121..0000000 --- a/setup.cfg +++ /dev/null @@ -1,25 +0,0 @@ -[metadata] -name = co2mini -version = 0.3.0 -author = Jeremy Mayeres -author_email = jeremy@jerr.dev -description = Monitor CO2 levels with Prometheus and/or HomeKit -url = https://github.com/jerr0328/co2-mini -long_description = file: README.md -long_description_content_type = text/markdown -classifiers = - Programming Language :: Python :: 3 - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Development Status :: 3 - Alpha - -[options] -packages = find: -install_requires = prometheus_client -python_requires = >=3.7 - -[options.entry_points] -console_scripts = co2mini = co2mini.main:main - -[options.extras_require] -homekit = HAP-python