Skip to content

Commit

Permalink
🔧 Upgrade CI, publishing (#10)
Browse files Browse the repository at this point in the history
Splitting from #8

- Update pre-commit hooks
- Switch from setup.cfg to pyproject.toml
- Update workflow versions
- Use PyPi trusted publishing
- Remove twine
- Use setuptools-scm for versioning
- Require python 3.9 or newer
  • Loading branch information
jerr0328 authored Nov 25, 2023
1 parent c41d78e commit ded2799
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: pre-commit

on:
"on":
pull_request:
push:
branches: [main]
Expand All @@ -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"
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
42 changes: 39 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" }, { 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]
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ flake8
isort
pre-commit
setuptools
twine
setuptools-scm
wheel
25 changes: 0 additions & 25 deletions setup.cfg

This file was deleted.

0 comments on commit ded2799

Please sign in to comment.