Created
July 10, 2017 21:41
-
-
Save voberoi/b43e3f388998f2fb63b86fd9bc367aa1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
## <project root>/ops/deploy.sh | |
PROJECT_ROOT=`git rev-parse --show-toplevel` | |
VERSION_FILE="$PROJECT_ROOT/atari_archive/VERSION" | |
# <rest of deploy script> | |
# Create version file based on tag or branch being deployed. | |
VERSION_STRING="$TAG_OR_BRANCH" | |
echo ">>>>> Creating VERSION file containing '$VERSION_STRING'..." | |
echo $VERSION_STRING > $VERSION_FILE | |
echo |
This file contains hidden or 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
## <project root>/setup.py | |
# Duplicate this here since setup.py doesn't (and probably shouldn't) import anything from the package it's packaging. | |
VERSION_FILE = os.path.join(os.path.dirname(__file__), "atari_archive", "VERSION") | |
def version_from_file(): | |
if not os.path.exists(VERSION_FILE): | |
return None | |
with open(VERSION_FILE) as fd: | |
return fd.read().strip() | |
setup( | |
name='atari_archive', | |
version=version_from_file() or "DEV", | |
# <rest of setup> |
This file contains hidden or 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
## <project root>/atari_archive/version.py | |
import os | |
# Created by deploy script. | |
VERSION_FILE = os.path.join(os.path.dirname(__file__), "VERSION") | |
def version_from_file(): | |
if not os.path.exists(VERSION_FILE): | |
return None | |
with open(VERSION_FILE) as fd: | |
return fd.read().strip() | |
# Import this for use in cache busting, etc. | |
__version__ = version_from_file() or "DEV" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, thanks!