From 196d4cc17866df2adf2ea2998a3ebfd0b878dafa Mon Sep 17 00:00:00 2001 From: Jules Dejaeghere Date: Sun, 16 Feb 2025 13:25:49 +0100 Subject: [PATCH] Configure bumpver and release workflow --- .github/workflows/release.yml | 27 +++++++++++++++++++++++++++ custom_components/irm_kmi/api.py | 5 +++-- custom_components/irm_kmi/const.py | 2 ++ custom_components/irm_kmi/pollen.py | 2 +- pyproject.toml | 18 ++++++++++++++++++ requirements_tests.txt | 3 ++- 6 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2fd254b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Create release + +on: + push: + tags: + - '*.*.*' + +permissions: + contents: write + +jobs: + tests: + uses: ./.github/workflows/pytest.yml + release: + name: Release pushed tag + needs: [tests] + runs-on: ubuntu-22.04 + steps: + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + run: | + gh release create "$tag" \ + --repo="$GITHUB_REPOSITORY" \ + --title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ + --generate-notes \ No newline at end of file diff --git a/custom_components/irm_kmi/api.py b/custom_components/irm_kmi/api.py index 44e53af..1624b02 100644 --- a/custom_components/irm_kmi/api.py +++ b/custom_components/irm_kmi/api.py @@ -10,6 +10,7 @@ from datetime import datetime import aiohttp import async_timeout from aiohttp import ClientResponse +from .const import USER_AGENT _LOGGER = logging.getLogger(__name__) @@ -70,9 +71,9 @@ class IrmKmiApiClient: ) -> any: """Get information from the API.""" if headers is None: - headers = {'User-Agent': 'github.com/jdejaegh/irm-kmi-ha'} + headers = {'User-Agent': USER_AGENT} else: - headers['User-Agent'] = 'github.com/jdejaegh/irm-kmi-ha' + headers['User-Agent'] = USER_AGENT try: async with async_timeout.timeout(60): diff --git a/custom_components/irm_kmi/const.py b/custom_components/irm_kmi/const.py index 4e0a427..71e44b8 100644 --- a/custom_components/irm_kmi/const.py +++ b/custom_components/irm_kmi/const.py @@ -159,3 +159,5 @@ IRM_KMI_NAME: Final = { } WEEKDAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] + +USER_AGENT: Final = 'github.com/jdejaegh/irm-kmi-ha 0.2.28' \ No newline at end of file diff --git a/custom_components/irm_kmi/pollen.py b/custom_components/irm_kmi/pollen.py index a692ab8..601bf35 100644 --- a/custom_components/irm_kmi/pollen.py +++ b/custom_components/irm_kmi/pollen.py @@ -3,7 +3,7 @@ import logging import xml.etree.ElementTree as ET from typing import List -from custom_components.irm_kmi.const import POLLEN_LEVEL_TO_COLOR, POLLEN_NAMES +from .const import POLLEN_LEVEL_TO_COLOR, POLLEN_NAMES _LOGGER = logging.getLogger(__name__) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c6c69b2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[tool.bumpver] +current_version = "0.2.28" +version_pattern = "MAJOR.MINOR.PATCH" +commit_message = "bump version {old_version} -> {new_version}" +tag_message = "{new_version}" +tag_scope = "default" +pre_commit_hook = "" +post_commit_hook = "" +commit = true +tag = true +push = true + +[tool.bumpver.file_patterns] +"pyproject.toml" = [ + 'current_version = "{version}"', +] +"custom_components/irm_kmi/manifest.json" = ['"version": "{version}"'] +"custom_components/irm_kmi/const.py" = ["'github.com/jdejaegh/irm-kmi-ha {version}'"] \ No newline at end of file diff --git a/requirements_tests.txt b/requirements_tests.txt index d15a75c..d26eab3 100644 --- a/requirements_tests.txt +++ b/requirements_tests.txt @@ -2,4 +2,5 @@ homeassistant==2025.2.4 pytest_homeassistant_custom_component==0.13.214 pytest freezegun -isort \ No newline at end of file +isort +bumpver \ No newline at end of file