Skip to content

Commit

Permalink
Draw package version from static data file included in package
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-douglass committed Apr 29, 2020
1 parent c58e60a commit 795f008
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
VERSION

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
2 changes: 2 additions & 0 deletions pipelines/azure-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ stages:
displayName: Set python version
inputs: {versionSpec: 3.8}
- script: |
export VERSION=${BUILD_SOURCEBRANCH#"refs/tags/v"}
echo $VERSION > assemblyline_ui/VERSION
sudo env "PATH=$PATH" python -m pip install --no-cache-dir -U wheel cython pip
python setup.py bdist_wheel
- publish: $(System.DefaultWorkingDirectory)/dist/
Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

from setuptools import setup, find_packages

# For development and local builds use this version number, but for real builds replace it
# with the tag found in the environment
# Try to load the version from a datafile in the package
package_version = "4.0.0.dev0"
if 'BITBUCKET_TAG' in os.environ:
package_version = os.environ['BITBUCKET_TAG'].lstrip('v')
elif 'BUILD_SOURCEBRANCH' in os.environ:
full_tag_prefix = 'refs/tags/v'
package_version = os.environ['BUILD_SOURCEBRANCH'][len(full_tag_prefix):]
package_version_path = os.path.join(os.path.dirname(__file__), 'assemblyline_ui', 'VERSION')
if os.path.exists(package_version_path):
with open(package_version_path) as package_version_file:
package_version = package_version_file.read().strip()

# read the contents of your README file
this_directory = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -83,7 +81,8 @@
"static/js/swal/*",
"static/js/ui-select/*",
"static/ng-template/*",
"static/pdf/*"
"static/pdf/*",
"VERSION",
]
}
)

0 comments on commit 795f008

Please sign in to comment.