From b6c852024d6968cdef5f33195393dd99dd180995 Mon Sep 17 00:00:00 2001 From: Jorn Bruggeman Date: Wed, 15 May 2024 10:28:36 +0100 Subject: [PATCH] tag-based version detection --- .github/workflows/publish_to_pypi.yml | 11 +++++++---- pyproject.toml | 7 +++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml index 7ebfff8..1b0bc07 100644 --- a/.github/workflows/publish_to_pypi.yml +++ b/.github/workflows/publish_to_pypi.yml @@ -1,4 +1,4 @@ -name: Publish Python to PyPI +name: Build and publish on: push @@ -9,6 +9,8 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v4 + with: + fetch-depth: 0 # for version detection by hatch-vcs/setuptools_scm - name: Set up Python uses: actions/setup-python@v5 - name: Install build @@ -16,12 +18,13 @@ jobs: - name: Build a binary wheel and a source tarball run: python -m build - name: Store the distribution packages - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: python-package-distributions path: dist/ publish-to-pypi: - name: Publish distribution to PyPI + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest environment: name: pypi @@ -30,7 +33,7 @@ jobs: id-token: write steps: - name: Download all the dists - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: python-package-distributions path: dist/ diff --git a/pyproject.toml b/pyproject.toml index a5af55c..166927c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] name = "pyncview" -version = "0.99.38" +dynamic = ["version"] readme = "README.md" dependencies = [ "xmlplot>=0.9.28", @@ -33,3 +33,6 @@ pyncview = "pyncview.pyncview:main" [tool.hatch.build.targets.sdist] only-include = ["pyncview"] + +[tool.hatch.version] +source = "vcs"