diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..81fd1e6 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,73 @@ +# This workflow will upload a Python Package to PyPI when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + release-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: "Set up Python" + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version-file: ".python-version" + + - name: Install uv + uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 + with: + version: "0.9.22" + enable-cache: false + + - name: Build release distributions + run: uv build + + - name: Upload distributions + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: release-dists + path: dist/ + + pypi-publish: + runs-on: ubuntu-latest + needs: + - release-build + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + + # Dedicated environments with protections for publishing are strongly recommended. + # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules + environment: + name: pypi + # ALTERNATIVE: if your GitHub Release name is the PyPI project version string + # ALTERNATIVE: exactly, uncomment the following line instead: + # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1 + with: + packages-dir: dist/ diff --git a/.gitignore b/.gitignore index 2e5836a..75aec2d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ static/ .idea/ .vscode/ *.venv/ +_version.py diff --git a/VERSION b/VERSION deleted file mode 100644 index c0490e5..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.5.34 diff --git a/docs/conf.py b/docs/conf.py index fc51203..1831ab1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,6 +12,7 @@ # import os import sys +from importlib.metadata import version sys.path.insert(0, os.path.abspath('..')) @@ -22,10 +23,7 @@ author = 'Stan Janssen' # The full version, including alpha/beta/rc tags -with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'VERSION')) as file: - release = file.read().strip() - -print(release) +release = version('openleadr') # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index f7d67b7..44ed17f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,16 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "openleadr/_version.py" + [project] name = "openleadr" -version = "0.5.34" +dynamic = ["version"] description = "Python3 library for building OpenADR Clients (VENs) and Servers (VTNs)" readme = "README.md" requires-python = ">=3.9" diff --git a/uv.lock b/uv.lock index 5496d54..b533b23 100644 --- a/uv.lock +++ b/uv.lock @@ -898,7 +898,7 @@ name = "exceptiongroup" version = "1.3.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "typing-extensions", marker = "python_full_version < '3.13'" }, + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" } wheels = [ @@ -1540,7 +1540,6 @@ wheels = [ [[package]] name = "openleadr" -version = "0.5.34" source = { editable = "." } dependencies = [ { name = "aiohttp", version = "3.13.5", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" },