Skip to content

Commit

Permalink
Better dynamic version handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dlobato committed May 2, 2024
1 parent 62809f6 commit 909d4af
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ jobs:
pip install
dunamai
--user
- name: Fix version
run: dunamai from git --no-metadata > VERSION
- name: Build a binary wheel and a source tarball
run: python3 -m build
run: DYNAMIC_VERSION=$(dunamai from git --no-metadata) python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ install:
$(PYTHON) setup.py install

sdist: clean ztpserver.spec
$(PYTHON) setup.py sdist
DYNAMIC_VERSION=$$(dunamai from git --no-metadata) $(PYTHON) setup.py sdist

sdist-dev: clean ztpserver.spec
DEV_VERSION_HASH=$$(git rev-parse --short HEAD) $(PYTHON) setup.py sdist
DYNAMIC_VERSION=$$(dunamai from git) $(PYTHON) setup.py sdist

docker_dev: sdist
@docker build -t ${IMG} .
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1.dev0
0.0.0 #uses dynamic version with: dunamai from git --no-metadata
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mock
dunamai
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def get_long_description():
x.strip() for x in install_requirements if x.strip() and "dev only" not in x
]
version = open("VERSION").read().split()[0].strip()
if os.environ.get("DYNAMIC_VERSION"):
version = os.environ.get("DYNAMIC_VERSION")
if os.environ.get("DEV_VERSION_HASH"):
version = f"{version}+{os.environ.get('DEV_VERSION_HASH')}"

Expand Down

0 comments on commit 909d4af

Please sign in to comment.