From e3bc7440243648b643d1d3b034549bd26fb4f607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Tue, 2 Oct 2018 13:21:39 +0200 Subject: [PATCH] Rename builds with version in Travis --- .travis.yml | 10 +++++++--- scripts/get_version.py | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 scripts/get_version.py diff --git a/.travis.yml b/.travis.yml index ab87ea68..56f6b734 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,6 +69,7 @@ script: fi after_success: + - export CUTTER_VERSION=$(python ../scripts/get_version.py) - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cp ../src/macos/Cutter.sh Cutter.app/Contents/MacOS/Cutter.sh && chmod +x Cutter.app/Contents/MacOS/Cutter.sh && macdeployqt Cutter.app -executable=Cutter.app/Contents/MacOS/Cutter && @@ -76,8 +77,9 @@ after_success: mkdir -p Cutter.app/Contents/Resources/r2/share && cp -a /usr/local/share/radare2 Cutter.app/Contents/Resources/r2/share/ && mkdir image && cp -a Cutter.app image/ && - hdiutil create -srcfolder image -volname Cutter -fs HFS+ Cutter.dmg && - export FILE_TO_UPLOAD="Cutter.dmg" + export DMG_FILE="Cutter-v$CUTTER_VERSION.dmg" && + hdiutil create -srcfolder image -volname Cutter -fs HFS+ "$DMG_FILE" && + export FILE_TO_UPLOAD="$DMG_FILE" ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make INSTALL_ROOT=appdir install && @@ -89,7 +91,9 @@ after_success: LD_LIBRARY_PATH=$CUSTOM_PYTHON_PREFIX/lib ./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -bundle-non-qt-libs -no-strip -exclude-libs=libnss3.so,libnssutil3.so -ignore-glob=usr/lib/python3.6/** -verbose=2 && LD_LIBRARY_PATH=$CUSTOM_PYTHON_PREFIX/lib ./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -appimage -no-strip -exclude-libs=libnss3.so,libnssutil3.so -ignore-glob=usr/lib/python3.6/** -verbose=2 && find ./appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq && - export FILE_TO_UPLOAD="Cutter-x86_64.AppImage" + export APPIMAGE_FILE="Cutter-v$CUTTER_VERSION-x86_64.AppImage" && + mv Cutter-x86_64.AppImage "$APPIMAGE_FILE" && + export FILE_TO_UPLOAD="$APPIMAGE_FILE" ; fi deploy: diff --git a/scripts/get_version.py b/scripts/get_version.py new file mode 100644 index 00000000..6ec7f82c --- /dev/null +++ b/scripts/get_version.py @@ -0,0 +1,23 @@ + +import os +import re + +scripts_path = os.path.dirname(os.path.realpath(__file__)) +pro_file_path = os.path.join(scripts_path, "..", "src", "Cutter.pro") + +with open(pro_file_path, "r") as f: + pro_content = f.read() + +def version_var_re(name): + return "^[ \t]*{}[ \t]*=[ \t]*(\d)+[ \t]*$".format(name) + +m = re.search(version_var_re("CUTTER_VERSION_MAJOR"), pro_content, flags=re.MULTILINE) +version_major = int(m.group(1)) if m is not None else 0 + +m = re.search(version_var_re("CUTTER_VERSION_MINOR"), pro_content, flags=re.MULTILINE) +version_minor = int(m.group(1)) if m is not None else 0 + +m = re.search(version_var_re("CUTTER_VERSION_PATCH"), pro_content, flags=re.MULTILINE) +version_patch = int(m.group(1)) if m is not None else 0 + +print("{}.{}.{}".format(version_major, version_minor, version_patch))