Skip to content

Commit 58f2053

Browse files
authored
Use setuptools-git-versioning (#213)
1 parent 646b07a commit 58f2053

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ jobs:
1414
uses: actions/setup-python@v4
1515
with:
1616
python-version: 3.8
17-
- name: Set package version
17+
- name: Build wheel
1818
run: |
19-
version="${{ github.event.release.tag_name }}"
20-
version="${version,,}" # lowercase it
21-
version="${version#v}" # remove `v`
22-
sed -i "s/version = \"0\.0\.0\"/version = \"${version}\"/" pyproject.toml
23-
- name: Install wheel
24-
run: >-
19+
VERSION="${{ github.event.release.tag_name }}"
20+
VERSION="${VERSION,,}" # lowercase it
21+
VERSION="${VERSION#v}" # remove `v`
22+
2523
pip install wheel build
26-
- name: Build
27-
run: >-
2824
python3 -m build
25+
26+
# Fail if we don't generate a package with the expected version
27+
if ( ! ls -A "dist/*${VERSION}*.whl" 1> /dev/null 2>&1 ); then
28+
exit 1
29+
fi
2930
- name: Publish distribution to PyPI
3031
uses: pypa/gh-action-pypi-publish@release/v1
3132
with:

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["setuptools>=61.0.0"]
2+
requires = ["setuptools>=61.0.0", "wheel", "setuptools-git-versioning<2"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "zigpy-znp"
7-
version = "0.0.0"
7+
dynamic = ["version"]
88
description = "A library for zigpy which communicates with TI ZNP radios"
99
urls = {repository = "https://github.com/zigpy/zigpy-znp"}
1010
authors = [
@@ -34,6 +34,9 @@ testing = [
3434
"coveralls",
3535
]
3636

37+
[tool.setuptools-git-versioning]
38+
enabled = true
39+
3740

3841
[tool.black]
3942
safe = true

0 commit comments

Comments
 (0)