diff --git a/.github/workflows/python_publish.yml b/.github/workflows/python_publish.yml new file mode 100644 index 0000000..b19d02f --- /dev/null +++ b/.github/workflows/python_publish.yml @@ -0,0 +1,32 @@ +name: Upload Python Package + +on: + release: + types: [published] + workflow_dispatch: + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.gitignore b/.gitignore index a03d37c..ac3b940 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ target/ .idea .hypothesis/ + +# Ignore auto-generated _version +/jsondiff/_version.py diff --git a/jsondiff/__init__.py b/jsondiff/__init__.py index 5e86701..8dc598a 100644 --- a/jsondiff/__init__.py +++ b/jsondiff/__init__.py @@ -1,5 +1,3 @@ -__version__ = '2.0.0' - import sys import json import yaml @@ -9,6 +7,7 @@ from .symbols import * from .symbols import Symbol +from ._version import __version__ # rules # - keys and strings which start with $ (or specified escape_str) are escaped to $$ (or escape_str * 2) diff --git a/pyproject.toml b/pyproject.toml index 2c822cc..1146f4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=43.0.0", "wheel"] +requires = ["setuptools>=64.0.0", "setuptools_scm>=8", "wheel"] build-backend = "setuptools.build_meta" [project] @@ -30,8 +30,10 @@ include = ["jsondiff*"] exclude = ["tests*"] [tool.setuptools.dynamic] -version = {attr = "jsondiff.__version__"} dependencies = {file=["requirements.txt"]} +[tool.setuptools_scm] +version_file = "jsondiff/_version.py" + [tool.setuptools.dynamic.optional-dependencies] dev = {file=["requirements-dev.txt"]} diff --git a/requirements-dev.txt b/requirements-dev.txt index 9a54149..4714fa4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,4 @@ hypothesis pytest +setuptools-scm +build \ No newline at end of file