Skip to content

Commit

Permalink
automation build and deploy v1
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszkula committed Apr 10, 2020
1 parent 7bd0322 commit 2628c94
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 6 deletions.
19 changes: 17 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
language: csharp
script: scripts/test.sh
language: objective-c
os: osx

env:
- UNITY_PROJECT_PATH="Action Race"

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

install:
- ./travis-scripts/install.sh

script:
- ./travis-scripts/build.sh

after_script:
- ./travis-scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MonoBehaviour:
m_Name: PhotonServerSettings
m_EditorClassIdentifier:
AppSettings:
AppIdRealtime: f47e7ba5-d87c-4340-b39a-ec4f1477bb99
AppIdRealtime:
AppIdChat:
AppIdVoice:
AppVersion:
Expand All @@ -31,7 +31,6 @@ MonoBehaviour:
RpcList:
- ClickRpc
- DestroyRpc
- Push
- TakeKick
DisableAutoOpenWizard: 1
ShowSettings: 0
8 changes: 8 additions & 0 deletions Action Race/Assets/Scripts/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Action Race/Assets/Scripts/Editor/AppBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using UnityEditor;

public class AppBuilder
{
public static void Build()
{
string[] scenes = { "Assets/Scenes/MainMenuScene.unity", "Assets/Scenes/Small Map.unity" };
BuildPipeline.BuildPlayer(scenes, "Build/WebGL", BuildTarget.WebGL, BuildOptions.None);
}
}
11 changes: 11 additions & 0 deletions Action Race/Assets/Scripts/Editor/AppBuilder.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions scripts/test.sh

This file was deleted.

17 changes: 17 additions & 0 deletions travis-scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /bin/sh

PROJECT_PATH="$(pwd)/$UNITY_PROJECT_PATH"
WEBGL_DIR="$PROJECT_PATH/Build/WebGL"

echo "Building WebGL..."
/Applications/Unity/Unity.app/Contents/MacOS/Unity \
-batchmode \
-nographics \
-silent-crashes \
-logFile \
-projectPath "$(PROJECT_PATH)" \
-executeMethod AppBuilder.Build \
-quit

echo "Zip WebGL files..."
zip -r nokia-game.zip "$WEBGL_DIR/Build" "$WEBGL_DIR/TemplateData" "$WEBGL_DIR/index.html"
37 changes: 37 additions & 0 deletions travis-scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/sh

if [[ -z "${BUTLER_API_KEY}" ]]; then
echo "Unable to deploy! No BUTLER_API_KEY environment variable specified!"
exit 1
fi

prepare_butler() {
echo "Preparing butler..."
download_if_not_exist https://broth.itch.ovh/butler/darwin-amd64/LATEST/archive/default butler.zip
unzip butler.zip
chmod +x butler
}

prepare_and_push() {
echo "Push $3 build to itch.io..."
./butler push $2 $1:$3
}

download_if_not_exist() {
if [ ! -f $2 ]; then
curl -L -o $2 $1
fi
}

echo "jestem w $(pwd)"

project="tomkul777/nokia-game"
artifact="nokia-game.zip"
platform="windows-beta"

prepare_butler

prepare_and_push $project $artifact $platform

echo "Done."
exit 0
37 changes: 37 additions & 0 deletions travis-scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/sh

UNITY_DOWNLOAD_CACHE="$(pwd)/unity_download_cache"
UNITY_OSX_PACKAGE_URL="https://download.unity3d.com/download_unity/46dda1414e51/MacEditorInstaller/Unity-2017.2.0f3.pkg"
UNITY_WEBGL_URL="https://beta.unity3d.com/download/46dda1414e51/MacEditorTargetInstaller/UnitySetup-WebGL-Support-for-Editor-2017.2.0f3.pkg"

#UNITY_OSX_PACKAGE_URL="https://download.unity3d.com/download_unity/4f139db2fdbd/MacEditorInstaller/Unity.pkg"
#UNITY_WEBGL_URL="https://download.unity3d.com/download_unity/4f139db2fdbd/MacEditorTargetInstaller/UnitySetup-WebGL-Support-for-Editor-2019.3.4f1.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 "Installing Unity..."
install $UNITY_OSX_PACKAGE_URL
install $UNITY_WEBGL_URL

0 comments on commit 2628c94

Please sign in to comment.