diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 00000000..25df117d --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,71 @@ +name: PyPI + +on: +- push: + tags: + - 'v*' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + +jobs: + archive: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + cache: pip + python-version: '3.11' + - run: python -m pip install build + - run: python -m build + - uses: actions/upload-artifact@v4 + with: + name: archive + path: dist/*.tar.gz + + build: + name: build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + permissions: + contents: read + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-13 + - macos-14 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + cache: pip + python-version: '3.11' + - run: python -m pip install build cibuildwheel==2.16.5 + - run: python -m cibuildwheel --output-dir wheelhouse + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }} + path: wheelhouse/*.whl + + release: + needs: + - archive + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/dispatch-functions + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + pattern: '*' + merge-multiple: true + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 75c6b53f..ce8bf76d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,11 @@ name: Test -on: [push] +on: +- push + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true permissions: contents: read @@ -10,14 +15,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ["3.11", "3.12"] + python: ['3.11', '3.12'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - cache: 'pip' + cache: pip - run: make dev - run: make test @@ -25,13 +30,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ["3.12"] + python: ['3.12'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - cache: 'pip' + cache: pip - run: make dev - run: make fmt-check diff --git a/.gitignore b/.gitignore index e1dea320..1d529437 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__ .proto .coverage .coverage-html +dist/ diff --git a/Makefile b/Makefile index 16bfebd6..3d3a2ad6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: install test typecheck unittest dev fmt fmt-check generate clean update-proto coverage +.PHONY: install test typecheck unittest dev fmt fmt-check generate clean update-proto coverage build check push push-test PYTHON := python @@ -50,8 +50,18 @@ generate: .proto/dispatch-sdk $(MAKE) fmt clean: - rm -rf .proto - rm -rf .coverage - rm -rf .coverage-html + $(RM) -rf dist .proto .coverage .coverage-html find . -type f -name '*.pyc' -exec rm {} \; find . -type d -name '__pycache__' -exec rm -r {} \; + +build: + $(PYTHON) -m build + +check: + twine check dist/* + +push: + twine upload dist/* + +push-test: + twine upload -r testpypi dist/* diff --git a/pyproject.toml b/pyproject.toml index e28c3fd4..0767028f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,32 +3,33 @@ requires = ["setuptools >= 61.0"] build-backend = "setuptools.build_meta" [project] -name = "dispatch-sdk" +name = "dispatch-functions" +description = "Python SDK for Dispatch Stateful Functions" +readme = "README.md" dynamic = ["version"] requires-python = ">= 3.11" -# TODO: relax dependency versions dependencies = [ - "grpcio==1.60.0", - "protobuf==4.24.0", - "types-protobuf==4.24.0.20240129", - "grpc-stubs", - "http_message_signatures==0.4.4" + "grpcio >= 1.60.0", + "protobuf >= 4.24.0", + "types-protobuf >= 4.24.0.20240129", + "grpc-stubs >= 1.53.0.5", + "http-message-signatures >= 0.4.4" ] [project.optional-dependencies] dev = [ - "black==24.1.0", - "isort==5.13.2", - "mypy==1.8.0", - "fastapi==0.109.0", - "httpx==0.26.0", - "coverage==7.4.1", - "requests==2.31.0", - "types-requests==2.31.0.20240125" + "black >= 24.1.0", + "isort >= 5.13.2", + "mypy >= 1.8.0", + "fastapi >= 0.109.0", + "httpx >= 0.26.0", + "coverage >= 7.4.1", + "requests >= 2.31.0", + "types-requests >= 2.31.0.20240125" ] -[tool.setuptools.dynamic] -version = {attr = "dispatch.__version__"} +[tool.setuptools-git-versioning] +enabled = true [tool.isort] profile = "black" diff --git a/src/dispatch/__init__.py b/src/dispatch/__init__.py index cc925e15..4f7fb181 100644 --- a/src/dispatch/__init__.py +++ b/src/dispatch/__init__.py @@ -21,5 +21,3 @@ "poll", "exit", ] - -__version__ = "0.0.1"