diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0ef4e2..4a9fa74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for setuptools-scm to detect version from tags - name: Set up Python uses: actions/setup-python@v5 diff --git a/README.md b/README.md index 43674b7..3ee673a 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,45 @@ meshcore-proxy --serial /dev/ttyUSB0 --port 5001 - Python 3.10+ - MeshCore companion radio with USB or BLE firmware +## Development + +### Building from Source + +```bash +git clone --recursive https://github.com/rgregg/meshcore-proxy.git +cd meshcore-proxy +pip install -e ".[dev]" +``` + +### Running Tests + +```bash +pytest +``` + +### Creating a Release + +This project uses [setuptools-scm](https://github.com/pypa/setuptools-scm) for automatic versioning based on git tags. + +**Version format:** Tags should follow the pattern `vX.Y.Z` or `vX.Y.Z-alpha` (e.g., `v0.4.0`, `v0.4.0-alpha`) + +**Release process:** + +1. Ensure all changes are committed and pushed +2. Create and push a version tag: + ```bash + git tag v0.4.0-alpha + git push origin v0.4.0-alpha + ``` +3. GitHub Actions will automatically: + - Build the package with the version from the tag + - Publish to PyPI + - Build and publish Docker images to GHCR + +**Version resolution:** +- On a tagged commit: uses the exact tag version (e.g., `v0.4.0-alpha` → `0.4.0a0`) +- Between tags: uses a dev version (e.g., `0.4.0a1.dev2` for 2 commits after `v0.4.0-alpha`) + ## License MIT diff --git a/pyproject.toml b/pyproject.toml index 31d64b2..9e02842 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=61.0", "wheel"] +requires = ["setuptools>=61.0", "wheel", "setuptools-scm>=8.0"] build-backend = "setuptools.build_meta" [project] name = "meshcore-proxy" -version = "0.1.0" +dynamic = ["version"] description = "TCP proxy for MeshCore companion radios" readme = "README.md" license = {text = "MIT"} @@ -54,3 +54,10 @@ select = ["E", "F", "W", "I", "N", "UP", "B", "C4"] [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"] + +[tool.setuptools_scm] +# Use guess-next-dev for versions between tags +# On a tagged commit, this will use the exact tag version +version_scheme = "guess-next-dev" +local_scheme = "no-local-version" +tag_regex = "^v(?P[0-9]+\\.[0-9]+\\.[0-9]+(-alpha|-beta|-rc[0-9]+)?)$" diff --git a/src/meshcore_proxy/__init__.py b/src/meshcore_proxy/__init__.py index f0f2436..1e1a157 100644 --- a/src/meshcore_proxy/__init__.py +++ b/src/meshcore_proxy/__init__.py @@ -1,3 +1,9 @@ """MeshCore Proxy - TCP proxy for MeshCore companion radios.""" -__version__ = "0.1.0" +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("meshcore-proxy") +except PackageNotFoundError: + # Package is not installed + __version__ = "0.0.0.dev0"