This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2829 from gratipay/improve-release.sh
Improve release.sh
- Loading branch information
Showing
4 changed files
with
86 additions
and
89 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
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,31 @@ | ||
from os.path import dirname, isdir, join | ||
import re | ||
from subprocess import CalledProcessError, check_output | ||
|
||
|
||
def get_version(): | ||
d = dirname(dirname(__file__)) | ||
|
||
if isdir(join(d, '.git')): | ||
# Get the version using "git describe". | ||
cmd = 'git describe --tags --match [0-9]*'.split() | ||
try: | ||
version = check_output(cmd).decode().strip() | ||
except CalledProcessError: | ||
print('Unable to get version number from git tags') | ||
exit(1) | ||
|
||
# PEP 386 compatibility | ||
if '-' in version: | ||
version = '.post'.join(version.split('-')[:2]) | ||
|
||
else: | ||
# Extract the version from the PKG-INFO file. | ||
with open(join(d, 'PKG-INFO')) as f: | ||
version = re.search('^Version: (.+)$', f.read(), re.M).group(1) | ||
|
||
return version | ||
|
||
|
||
if __name__ == '__main__': | ||
print(get_version()) |
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
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