From 8aeef938fc6e5a9a13d4dc77757a4026d6c4cec5 Mon Sep 17 00:00:00 2001 From: Lukas Werling Date: Sun, 23 Sep 2018 23:19:17 +0200 Subject: [PATCH] Travis: Build and upload AppImage snapshot --- .travis.yml | 16 ++++++++++++++-- tools/create_appimage.sh | 22 ++++++++++++++++++++++ tools/upload_snapshot.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100755 tools/create_appimage.sh create mode 100755 tools/upload_snapshot.sh diff --git a/.travis.yml b/.travis.yml index c2a1bb425..e366e25c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,13 +23,15 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-5', 'build-essential', 'cmake', 'libfreetype6-dev', 'libgl1-mesa-dev', 'libglew-dev', 'libgtk-3-dev', 'libjpeg-dev', 'libpng-dev', 'libsdl2-dev', 'libupnp-dev', 'libxrandr-dev', 'x11proto-core-dev', 'zlib1g-dev', 'libalut0', 'ninja-build', 'libgtest-dev'] + packages: ['g++-5', 'build-essential', 'cmake', 'libfreetype6-dev', 'libgl1-mesa-dev', 'libglew-dev', 'libgtk-3-dev', 'libjpeg-dev', 'libpng-dev', 'libsdl2-dev', 'libupnp-dev', 'libxrandr-dev', 'x11proto-core-dev', 'zlib1g-dev', 'libalut0', 'ninja-build', 'libgtest-dev', 'curl'] env: - CCOMPILER=gcc-5 - CXXCOMPILER=g++-5 - - TYPE=Debug + - TYPE=RelWithDebInfo - CXX_FLAGS="-fdiagnostics-color" - BSYS="Ninja#ninja -k30" PCH=on + - UPLOAD_SNAPSHOT=1 + - CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=/usr -DWITH_AUTOMATIC_UPDATE=ON -DWITH_APPDIR_INSTALLATION=ON" - os: linux compiler: clang @@ -57,9 +59,19 @@ before_script: -DUSE_GCC_PCH=${PCH:-off} -DGTEST_ROOT=$PWD/googletest-release-1.7.0 -DGMOCK_ROOT=$PWD/googlemock-release-1.7.0 + $CMAKE_FLAGS . script: - ${BSYS/*#/} all netpuncher tests aul_test - ./tests/tests - ./tests/aul_test + +after_success: + - > + [ "$UPLOAD_SNAPSHOT" = 1 ] && + echo "Creating AppImage..." && + tools/create_appimage.sh && + echo "Uploading snapshot..." && + tools/upload_snapshot.sh OpenClonk-x86_64.AppImage || + echo "Snapshot creation has failed" diff --git a/tools/create_appimage.sh b/tools/create_appimage.sh new file mode 100755 index 000000000..4cad3c721 --- /dev/null +++ b/tools/create_appimage.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +error() { + echo error: "$@" + exit 1 +} + +[[ -f CMakeCache.txt ]] || error "this does not look like a build directory" + +DESTDIR=appdir cmake --build . --target install || error "install failed" + +linuxdeployqt=linuxdeployqt-continuous-x86_64.AppImage +if [[ ! -x $linuxdeployqt ]]; then + wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/$linuxdeployqt" \ + || error "could not download linuxdeployqt" + chmod a+x $linuxdeployqt +fi + +export ARCH=$(uname -m) + +./$linuxdeployqt appdir/usr/share/applications/openclonk.desktop -appimage \ + || error "AppImage creation has failed" diff --git a/tools/upload_snapshot.sh b/tools/upload_snapshot.sh new file mode 100755 index 000000000..227298375 --- /dev/null +++ b/tools/upload_snapshot.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +error() { + echo error: "$@" + exit 1 +} + +revision=$(git rev-parse --short=9 HEAD) +[[ -n $revision ]] || error "could not get git revision" + +branch=$(git symbolic-ref --short HEAD) +# Travis checks out a concrete revision, so we have to get the branch name from +# the environment instead. +: ${branch:=$TRAVIS_BRANCH} +[[ -n $branch ]] || error "could not get branch name" + +date=$(date --date="$(git show -s --format=%ci)" -u -Is | sed 's/+00:\?00$/Z/') +[[ -n $date ]] || error "could not get commit date" + +file=${1:?no file to upload given} +: ${OC_REL_URL:?target URL not set} + +upload_path="/snapshots/$date-$branch-$revision/$(basename "$file")" +echo "uploading $upload_path" + +curl -XPOST "$OC_REL_URL$upload_path" --data-binary "@$file" \ + || error "file upload failed"