Skip to content

Instantly share code, notes, and snippets.

@voberoi
Created July 10, 2017 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voberoi/b43e3f388998f2fb63b86fd9bc367aa1 to your computer and use it in GitHub Desktop.
Save voberoi/b43e3f388998f2fb63b86fd9bc367aa1 to your computer and use it in GitHub Desktop.
## <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
## <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>
## <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"
@chuckgroom
Copy link

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment