Skip to content

Commit

Permalink
added travis build
Browse files Browse the repository at this point in the history
  • Loading branch information
marlon360 committed Apr 25, 2019
1 parent c0695ae commit a7cdfad
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
language: objective-c
osx_image: xcode9.2
rvm:
- 2.2 #see before_install for getting RVM stable.

env:
- TRAVIS_TAG="Deploy-2019.1" PROJECT_NAME="CubeShooter" UNITY_PROJECT_PATH="./" DEPLOY_UNITYPACKAGE="path set in deploy script"


cache:
directories:
- $UNITY_DOWNLOAD_CACHE


before_install:
- chmod a+x ./travis-build/*.sh

install:
- cat /etc/hosts
- ./travis-build/install-unity.sh

script:
- ./travis-build/build.sh
- ./travis-build/run-tests.sh

after_success:
- ./travis-build/export-unity-package.sh

before_deploy:
- DEPLOY_UNITYPACKAGE="$(ls -a release/*.zip | head -n 1)"

deploy:
provider: releases
api_key: $GITHUB_TOKEN
file: $DEPLOY_UNITYPACKAGE
skip_cleanup: true
overwrite: true
on:
tags: true
37 changes: 37 additions & 0 deletions travis-build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/sh

PROJECT_PATH=$(pwd)/$UNITY_PROJECT_PATH
UNITY_BUILD_DIR=$(pwd)/Build
LOG_FILE=$UNITY_BUILD_DIR/unity-win.log


ERROR_CODE=0
echo "Items in project path ($PROJECT_PATH):"
ls "$PROJECT_PATH"


echo "Building project for Windows..."
mkdir $UNITY_BUILD_DIR
/Applications/Unity/Unity.app/Contents/MacOS/Unity \
-batchmode \
-nographics \
-silent-crashes \
-logFile \
-projectPath "$PROJECT_PATH" \
-buildWindows64Player "$(pwd)/build/win/ci-build.exe" \
-quit \
| tee "$LOG_FILE"

if [ $? = 0 ] ; then
echo "Building Windows exe completed successfully."
ERROR_CODE=0
else
echo "Building Windows exe failed. Exited with $?."
ERROR_CODE=1
fi

#echo 'Build logs:'
#cat $LOG_FILE

echo "Finishing with code $ERROR_CODE"
exit $ERROR_CODE
57 changes: 57 additions & 0 deletions travis-build/export-unity-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#! /bin/sh

PROJECT_PATH=$(pwd)/$UNITY_PROJECT_PATH
UNITY_BUILD_DIR=$(pwd)/Build
LOG_FILE=$UNITY_BUILD_DIR/unity-win.log
EXPORT_PATH=$(pwd)/$PROJECT_NAME-v"$TRAVIS_TAG"-b"$TRAVIS_BUILD_NUMBER".unitypackage
RELEASE_DIRECTORY=./release


ERROR_CODE=0

echo "Creating package at=$EXPORT_PATH"
mkdir $UNITY_BUILD_DIR
/Applications/Unity/Unity.app/Contents/MacOS/Unity \
-batchmode \
-nographics \
-silent-crashes \
-logFile \
-projectPath "$PROJECT_PATH" \
-exportPackage "Assets" "$EXPORT_PATH" \
-quit \
| tee "$LOG_FILE"

if [ $? = 0 ] ; then
echo "Created package successfully."
ERROR_CODE=0

echo "Packaging unity package into release..."
#Preprare release unity package by packing into ZIP
RELEASE_ZIP_FILE=$RELEASE_DIRECTORY/$PROJECT_NAME-v$TRAVIS_TAG.zip

mkdir -p $RELEASE_DIRECTORY

echo "Preparing release for version: $TRAVIS_TAG"
cp "$EXPORT_PATH" "$RELEASE_DIRECTORY/"`basename "$EXPORT_PATH"`
cp "./README.md" "$RELEASE_DIRECTORY"
cp "./LICENSE" "$RELEASE_DIRECTORY"

echo "Files in release directory:"
ls $RELEASE_DIRECTORY

zip -6 -r $RELEASE_ZIP_FILE $RELEASE_DIRECTORY

echo "Release zip package ready. Zipinfo:"
zipinfo $RELEASE_ZIP_FILE

else
echo "Creating package failed. Exited with $?."
ls
ERROR_CODE=1
fi

#echo 'Build logs:'
#cat $LOG_FILE

echo "Export finished with code $ERROR_CODE"
exit $ERROR_CODE
42 changes: 42 additions & 0 deletions travis-build/install-unity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#! /bin/sh

# See https://unity3d.com/get-unity/download/archive
# to get download URLs
UNITY_DOWNLOAD_CACHE="$(pwd)/unity_download_cache"
UNITY_OSX_PACKAGE_URL="https://download.unity3d.com/download_unity/292b93d75a2c/MacEditorInstaller/Unity-2019.1.0f2.pkg"
UNITY_WINDOWS_TARGET_PACKAGE_URL="https://download.unity3d.com/download_unity/292b93d75a2c/MacEditorTargetInstaller/UnitySetup-Windows-Mono-Support-for-Editor-2019.1.0f2.pkg"


# Downloads a file if it does not exist
download() {

URL=$1
FILE=`basename "$URL"`

# Downloads a package if it does not already exist in cache
if [ ! -e $UNITY_DOWNLOAD_CACHE/`basename "$URL"` ] ; then
echo "$FILE does not exist. Downloading from $URL: "
mkdir -p "$UNITY_DOWNLOAD_CACHE"
curl -o $UNITY_DOWNLOAD_CACHE/`basename "$URL"` "$URL"
else
echo "$FILE Exists. Skipping download."
fi
}

# Downloads and installs a package from an internet URL
install() {
PACKAGE_URL=$1
download $1

echo "Installing `basename "$PACKAGE_URL"`"
sudo installer -dumplog -package $UNITY_DOWNLOAD_CACHE/`basename "$PACKAGE_URL"` -target /
}



echo "Contents of Unity Download Cache:"
ls $UNITY_DOWNLOAD_CACHE

echo "Installing Unity..."
install $UNITY_OSX_PACKAGE_URL
install $UNITY_WINDOWS_TARGET_PACKAGE_URL
4 changes: 4 additions & 0 deletions travis-build/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/sh

echo "Skipping testing. No Tests implemented yet..."
exit 0

0 comments on commit a7cdfad

Please sign in to comment.