diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d5b8c18 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release to PyPI + +on: + release: + types: + - published + +jobs: + publish-to-pypi: + runs-on: ubuntu-latest + permissions: + id-token: write + + + steps: + # Checkout the repository + - name: Checkout code + uses: actions/checkout@v4 + + # Set up Python + - name: Setup uv + uses: astral-sh/setup-uv@v6 + with: + version: "0.7.8" + enable-cache: true + cache-dependency-glob: | + pyproject.toml + + - name: Build package distributions + run: uv build + + # Publish to PyPI + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 580d47c..65b83d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Code Quality Checks +name: Lint/Test on: push: @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout code @@ -59,7 +59,7 @@ jobs: - name: Run pytest run: uv run python -m pytest --cov=python_cayennelpp tests/ --cov-report=xml - - name: Code ./coverage1.xml + - name: Code Coverage uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index ea5a245..84d34c9 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Open-source library for python to decode CayenneLPP format payload. The Cayenne Low Power Payload (LPP) provides a convenient and easy way to send data over LPWAN networks such as LoRaWAN. More details on CayenneLPP payload: https://github.com/myDevicesIoT/cayenne-docs +> Note: while Python versions 2.7 and <=3.7 may work, they're not officially supported since they're EOL. + ## Installation To install the package use next pip command @@ -23,6 +25,7 @@ To decode payload simply use method decode() from this package >>>print(decode('03670110056700FF')) [{'channel': 3, 'name': 'Temperature Sensor', 'value': 27.2}, {'channel': 5, 'name': 'Temperature Sensor', 'value': 25.5}] ``` + ## Additional info The package may raise following exceptions: - `TypeError` - if the provided data is not of the `str` type diff --git a/pyproject.toml b/pyproject.toml index d5afc13..c5deded 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,3 +42,8 @@ dev = [ "ruff>=0.11.12", ] +[[tool.uv.index]] +name = "testpypi" +url = "https://test.pypi.org/simple/" +publish-url = "https://test.pypi.org/legacy/" +explicit = true diff --git a/python_cayennelpp/__init__.py b/python_cayennelpp/__init__.py index b4ed04a..a7de90e 100644 --- a/python_cayennelpp/__init__.py +++ b/python_cayennelpp/__init__.py @@ -1 +1,3 @@ """Python CayenneLPP decoder library.""" + +__version__ = "0.0.5" diff --git a/python_cayennelpp/decoder.py b/python_cayennelpp/decoder.py index e96eb4a..95e3535 100644 --- a/python_cayennelpp/decoder.py +++ b/python_cayennelpp/decoder.py @@ -1,7 +1,7 @@ """Main decoder for CayenneLPP payload format.""" import logging -from typing import Any +from typing import Any, Dict, List from python_cayennelpp.methods import hex_library logger = logging.getLogger(__name__) @@ -26,7 +26,7 @@ def decode(payload: str): ) # parsing payload using hex_library. # variable pointer represents caret in line to cut. result is returned result - result: list[dict[str, Any]] = [] + result: List[Dict[str, Any]] = [] pointer = 0 try: while pointer < len(payload): diff --git a/python_cayennelpp/methods.py b/python_cayennelpp/methods.py index d31c11c..ed5053f 100644 --- a/python_cayennelpp/methods.py +++ b/python_cayennelpp/methods.py @@ -1,6 +1,6 @@ """This module contains methods to decode CayenneLPP sensor data.""" -from typing import Any +from typing import Any, Dict def hex_to_int(hex_string: str, signed: bool = True): @@ -114,7 +114,7 @@ def gps_location(data: str): } -hex_library: dict[str, dict[str, Any]] = { +hex_library: Dict[str, Dict[str, Any]] = { "00": { "name": "Digital Input", "size": 2,