From 58f2053e912414d63e1351ddca01ca282cdb2b28 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Mon, 24 Apr 2023 14:07:14 -0400 Subject: [PATCH] Use `setuptools-git-versioning` (#213) --- .github/workflows/publish-to-pypi.yml | 19 ++++++++++--------- pyproject.toml | 7 +++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 6a6124dd..235902b9 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -14,18 +14,19 @@ jobs: uses: actions/setup-python@v4 with: python-version: 3.8 - - name: Set package version + - name: Build wheel run: | - version="${{ github.event.release.tag_name }}" - version="${version,,}" # lowercase it - version="${version#v}" # remove `v` - sed -i "s/version = \"0\.0\.0\"/version = \"${version}\"/" pyproject.toml - - name: Install wheel - run: >- + VERSION="${{ github.event.release.tag_name }}" + VERSION="${VERSION,,}" # lowercase it + VERSION="${VERSION#v}" # remove `v` + pip install wheel build - - name: Build - run: >- python3 -m build + + # Fail if we don't generate a package with the expected version + if ( ! ls -A "dist/*${VERSION}*.whl" 1> /dev/null 2>&1 ); then + exit 1 + fi - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/pyproject.toml b/pyproject.toml index e6cfeb70..37131b99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=61.0.0"] +requires = ["setuptools>=61.0.0", "wheel", "setuptools-git-versioning<2"] build-backend = "setuptools.build_meta" [project] name = "zigpy-znp" -version = "0.0.0" +dynamic = ["version"] description = "A library for zigpy which communicates with TI ZNP radios" urls = {repository = "https://github.com/zigpy/zigpy-znp"} authors = [ @@ -34,6 +34,9 @@ testing = [ "coveralls", ] +[tool.setuptools-git-versioning] +enabled = true + [tool.black] safe = true