Skip to content

Commit b31fb7a

Browse files
authored
Replace VERSION variable with setuptools_scm for versioning (#57)
* Use setuptools_scm instead of env for version handling * Update Github Actions Signed-off-by: <contact@nlach.fr>
1 parent 1b03496 commit b31fb7a

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

.github/workflows/on-release-tag.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
- name: Install dependencies
2525
run: |
2626
python -m pip install --upgrade pip
27-
pip install setuptools wheel twine
27+
pip install setuptools setuptools_scm wheel twine
2828
- name: Publish to Pypi
2929
run: |
30-
rm -rf dist; VERSION=${{ env.glustercli_version }} python3 setup.py sdist bdist_wheel;
30+
rm -rf dist; python3 setup.py sdist bdist_wheel;
3131
TWINE_PASSWORD=${{ secrets.TWINE_PASSWORD }} twine upload --username aravindavk dist/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ pycscope.*
88
build
99
dist
1010
docs/_build
11+
glustercli/_version.py
1112
.DS_Store
1213
_build

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
write_to = "glustercli/_version.py"

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import os
22
import re
33
from setuptools import setup
4+
from importlib.metadata import version, PackageNotFoundError
45

5-
VERSION = os.environ.get("VERSION", "master")
6-
6+
try:
7+
__version__ = version('glustercli')
8+
except PackageNotFoundError:
9+
__version__ = "unknown"
710

811
setup(
912
name='glustercli',
10-
version=VERSION,
13+
version=__version__,
1114
description='Python bindings for GlusterFS CLI and Metrics collection',
1215
license='GPLv2 or LGPLv3+',
1316
author='Aravinda Vishwanathapura',

0 commit comments

Comments
 (0)