-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: pull setup.py version from git tag
If the current commit isn't tagged a 'dev' tag will be generated from the most recently tag + number of commits
- Loading branch information
Showing
3 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import setuptools | ||
from tools.git_tag import get_current_version_tag | ||
|
||
with open("README.md", "r") as readme_file: | ||
long_description = readme_file.read() | ||
|
||
setuptools.setup( | ||
name="nitric", | ||
version="0.1.0", | ||
version=get_current_version_tag(), | ||
author="Nitric", | ||
author_email="[email protected]", | ||
description="The Nitric SDK for Python 3", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/nitrictech/python-sdk", | ||
packages=setuptools.find_packages(), | ||
packages=setuptools.find_packages(".", exclude=["tests", "tools"]), | ||
license_files=("LICENSE.txt",), | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import re | ||
from subprocess import Popen, PIPE | ||
|
||
|
||
def get_current_version_tag(): | ||
process = Popen(["git", "describe", "--tags", "--match", "v[0-9]*"], stdout=PIPE) | ||
(output, err) = process.communicate() | ||
process.wait() | ||
|
||
tags = str(output, "utf-8").strip().split("\n") | ||
|
||
version_tags = [tag for tag in tags if re.match(r"^v?(\d*\.){2}\d$", tag)] | ||
dev_tags = [tag for tag in tags if re.match(r"^v?(\d*\.){2}\d-\d*-[a-z\d]{8}$", tag)] | ||
|
||
if len(version_tags) == 1: | ||
return version_tags.pop()[1:] | ||
elif len(dev_tags) == 1: | ||
base_tag, num_commits = dev_tags.pop().split("-")[:2] | ||
return "{}.dev{}".format(base_tag, num_commits)[1:] | ||
else: | ||
raise Exception("Unable to determine or construct version from git tags.") |