diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..4cede4b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish to PyPI + +on: + push: + branches: [ master ] + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Build package + run: uv build + + - name: Publish to PyPI + run: uv publish diff --git a/hasql/__init__.py b/hasql/__init__.py index a4c7f2c..0bfcc6f 100644 --- a/hasql/__init__.py +++ b/hasql/__init__.py @@ -1,5 +1,4 @@ -__version_info__ = (0, 9, 0) -__version__ = ".".join(map(str, __version_info__)) +from hasql.version import __version__ package_info = ( "hasql is a module for acquiring actual connections with masters " diff --git a/pyproject.toml b/pyproject.toml index 5f3fb5c..d2c3fb0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=69", "wheel"] +requires = ["setuptools>=69", "wheel", "setuptools_scm>=8"] build-backend = "setuptools.build_meta" [project] @@ -80,10 +80,10 @@ Tracker = "https://github.com/aiokitchen/hasql/issues" Documentation = "https://github.com/aiokitchen/hasql/blob/master/README.rst" [tool.setuptools.dynamic] -version = { attr = "hasql.__version__" } +version = { attr = "hasql.version.__version__" } [tool.setuptools.packages.find] -exclude = ["tests*", "example*"] +include = ["hasql*"] [tool.setuptools.package-data] hasql = ["py.typed"] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..791b814 --- /dev/null +++ b/setup.py @@ -0,0 +1,23 @@ +from setuptools import setup + + +def version_scheme(version): + """Custom version: MAJOR.MINOR.COMMITS_SINCE_TAG""" + if version.exact: + return f"{version.tag}.0" + return f"{version.tag}.{version.distance}" + + +def local_scheme(version): + """No local version component.""" + return "" + + +setup( + use_scm_version={ + "version_scheme": version_scheme, + "local_scheme": local_scheme, + "tag_regex": r"^v(?P\d+\.\d+)$", + "write_to": "hasql/version.py", + } +)