Skip to content

Commit

Permalink
Merge pull request gradio-app#7 from gradio-app/publish
Browse files Browse the repository at this point in the history
Publish to pypi action
  • Loading branch information
abidlabs authored Dec 2, 2024
2 parents c94bd37 + b97b63d commit 7712d1b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
dependencies = [
"httpx",
]
dynamic = ["version"]

[project.urls]
homepage = "https://github.com/gradio-app/safehttpx"
Expand All @@ -30,3 +31,6 @@ dev = ["pytest"]
[tool.hatch.build.targets.wheel]
packages = ["safehttpx"]

[tool.hatch.version]
path = "version.txt"
pattern = "^(?P<version>[0-9]+\\.[0-9]+\\.[0-9]+)$"
7 changes: 6 additions & 1 deletion safehttpx/__init__.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.2
34 changes: 34 additions & 0 deletions workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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/*

0 comments on commit 7712d1b

Please sign in to comment.