From 74da79334b276681879a131a253833fde129ed70 Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Mon, 2 Dec 2024 12:53:02 -0500 Subject: [PATCH 1/3] changes --- safehttpx/__init__.py | 7 ++++++- version.txt | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 version.txt diff --git a/safehttpx/__init__.py b/safehttpx/__init__.py index 935521b..05153f4 100644 --- a/safehttpx/__init__.py +++ b/safehttpx/__init__.py @@ -1,13 +1,18 @@ import asyncio import ipaddress +from pathlib import Path import socket from functools import lru_cache, wraps from typing import Any, Awaitable, Callable, Coroutine, Literal, T, Tuple import httpx -__version__ = "0.1.1" +def get_version(): + version_file = Path(__file__).parent.parent / 'version.txt' + with open(version_file, 'r') as f: + return f.read().strip() +__version__ = get_version() def is_public_ip(ip: str) -> bool: try: diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..8294c18 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.1.2 \ No newline at end of file From 8ab36a332c2300b0c635751777173f9eb43d945b Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Mon, 2 Dec 2024 12:53:56 -0500 Subject: [PATCH 2/3] changes --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 6e43f77..dd2eb0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ classifiers = [ dependencies = [ "httpx", ] +dynamic = ["version"] [project.urls] homepage = "https://github.com/gradio-app/safehttpx" @@ -30,3 +31,6 @@ dev = ["pytest"] [tool.hatch.build.targets.wheel] packages = ["safehttpx"] +[tool.hatch.version] +path = "version.txt" +pattern = "^(?P[0-9]+\\.[0-9]+\\.[0-9]+)$" From b97b63d8889c4375725b54e3f65b01b7667ed572 Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Mon, 2 Dec 2024 12:54:27 -0500 Subject: [PATCH 3/3] publish --- workflows/publish.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 workflows/publish.yml diff --git a/workflows/publish.yml b/workflows/publish.yml new file mode 100644 index 0000000..de1f80e --- /dev/null +++ b/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish to PyPI + +on: + push: + branches: + - main + paths: + - 'version.txt' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + + - name: Build package + run: python -m build + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + python -m twine upload dist/* \ No newline at end of file