Skip to content

Commit 29e64ee

Browse files
committed
add ci
1 parent 048f55b commit 29e64ee

3 files changed

Lines changed: 253 additions & 0 deletions

File tree

Scripts/build.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#! /bin/sh
2+
# exit this script if any commmand fails
3+
4+
5+
echo "Run test "
6+
/Applications/Unity/Unity.app/Contents/MacOS/Unity \
7+
-batchmode \
8+
-nographics \
9+
-silent-crashes \
10+
-logFile $(pwd)/unity.log \
11+
-projectPath $(pwd) \
12+
-runEditorTests \
13+
-quit
14+
15+
code=$?
16+
cat $(pwd)/unity.log
17+
if [ "$code" != "0" ]; then
18+
exit $code
19+
fi
20+
21+
22+
# project="ci-build"
23+
24+
# dobuild $plantform $buildcmd $outputpath
25+
# dobuild() {
26+
# rm -rf "$(pwd)/unity.log"
27+
# echo "Attempting to build $project for $1"
28+
# set +e
29+
# /Applications/Unity/Unity.app/Contents/MacOS/Unity \
30+
# -batchmode \
31+
# -nographics \
32+
# -silent-crashes \
33+
# -logFile $(pwd)/unity.log \
34+
# -projectPath $(pwd) \
35+
# -"$2" "$3" \
36+
# -quit
37+
38+
39+
# code=$?
40+
# cat "$(pwd)/unity.log"
41+
# if [ "$code" != "0" ]; then
42+
# echo "Build fail for $1"
43+
# # exit script without bash
44+
# # kill -"$code" $$
45+
# exit
46+
# fi
47+
# }
48+
49+
# dobuild "Windows" buildWindowsPlayer "$(pwd)/Build/windows/$project.exe"
50+
# dobuild "0S X" buildOSXUniversalPlayer "$(pwd)/Build/osx/$project.app"
51+
# dobuild "Linux" buildLinuxUniversalPlayer "$(pwd)/Build/linux/$project.exe"
52+
53+
54+
55+
56+
# function doWindows()
57+
# echo "Attempting to build $project for $2"
58+
# /Applications/Unity/Unity.app/Contents/MacOS/Unity \
59+
# -batchmode \
60+
# -nographics \
61+
# -silent-crashes \
62+
# -logFile $(pwd)/unity.log \
63+
# -projectPath $(pwd) \
64+
# -buildWindowsPlayer "$(pwd)/Build/windows/$project.exe" \
65+
# -quit
66+
67+
# if [[ $? ]]; then
68+
# #statements
69+
# fi
70+
# cat "$(pwd)/unity.log"
71+
# rm -rf "$(pwd)/unity.log"
72+
73+
# echo "Attempting to build $project for OS X"
74+
# /Applications/Unity/Unity.app/Contents/MacOS/Unity \
75+
# -batchmode \
76+
# -nographics \
77+
# -silent-crashes \
78+
# -logFile $(pwd)/unity.log \
79+
# -projectPath $(pwd) \
80+
# -buildOSXUniversalPlayer "$(pwd)/Build/osx/$project.app" \
81+
# -quit
82+
83+
# cat "$(pwd)/unity.log"
84+
# rm -rf "$(pwd)/unity.log"
85+
86+
# echo "Attempting to build $project for Linux"
87+
# /Applications/Unity/Unity.app/Contents/MacOS/Unity \
88+
# -batchmode \
89+
# -nographics \
90+
# -silent-crashes \
91+
# -logFile $(pwd)/unity.log \
92+
# -projectPath $(pwd) \
93+
# -buildLinuxUniversalPlayer "$(pwd)/Build/linux/$project.exe" \
94+
# -quit
95+
96+
# cat "$(pwd)/unity.log"
97+
# rm -rf "$(pwd)/unity.log"

Scripts/install.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#! /bin/sh
2+
# exit this script if any commmand fails
3+
set -e
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
7+
echo "Get Unity version for $UNITY_VERSION"
8+
url=$(python $DIR/unitydownloadurl.py -v $UNITY_VERSION --os mac)
9+
realVersion=${url/*-/}
10+
realVersion=${realVersion/.pkg*/}
11+
realVersion=${realVersion/.dmg*/}
12+
echo "Got Unity version:$realVersion"
13+
echo "Got Unity url:$url"
14+
15+
dmg=${url/*.dmg*/}
16+
pkgname="Unity.pkg"
17+
echo "Downloading from $url: "
18+
if [ -z $dmg ]; then
19+
curl -o Unity.dmg "$url"
20+
sudo hdiutil attach Unity.dmg
21+
ls /Volumes/Unity\ Download\ Assistant
22+
pkgname="/Volumes/Unity Download Assistant/Unity.pkg"
23+
else
24+
curl -o Unity.pkg "$url"
25+
fi
26+
27+
echo 'Installing Unity.pkg'
28+
sudo installer -dumplog -package $pkgname -target /

Scripts/unitydownloadurl.py

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/python
2+
# coding=utf-8
3+
4+
5+
from optparse import OptionParser
6+
import urllib
7+
import re
8+
9+
def getRealBetaUrlTuples(pageUrl):
10+
f = urllib.urlopen(pageUrl)
11+
data = f.read()
12+
# <a href="http://beta.unity3d.com/download/0df597686c75/Windows64EditorInstaller/UnitySetup64-5.4.0b19.exe">Unity Editor 64-bit &#40;Win&#41;</a>
13+
# <a href="http://beta.unity3d.com/download/0df597686c75/MacEditorInstaller/Unity-5.4.0b19.pkg">Unity Editor &#40;Mac&#41;</a>
14+
urlTuples = re.findall(r'<a href="(https?://[^"]*?(UnityDownloadAssistant|EditorInstaller/Unity.*?)-([^"]*?)\.(pkg|dmg|exe))">Unity Editor.*?</a>', data)
15+
return urlTuples
16+
17+
def getBetaUrlTuples():
18+
f = urllib.urlopen("https://unity3d.com/unity/beta/archive")
19+
data = f.read()
20+
# <a href="/unity/beta/unity5.4.0b19">Download</a>
21+
urlTuples = re.findall(r'<a href="([^"]*?/unity/beta/[^"]*?)">Download</a>', data)
22+
if len(urlTuples) > 0:
23+
url = urlTuples[0]
24+
if url.startswith("/"):
25+
url = "https://unity3d.com" + url
26+
return getRealBetaUrlTuples(url)
27+
28+
return None
29+
30+
def getUrlTuples():
31+
f = urllib.urlopen("https://unity3d.com/get-unity/download/archive")
32+
data = f.read()
33+
# <a href="http://netstorage.unity3d.com/unity/960ebf59018a/Windows64EditorInstaller/UnitySetup64-5.3.5f1.exe">Unity Editor 64-bit</a>
34+
# <a href="http://download.unity3d.com/download_unity/0b02744d4013/MacEditorInstaller/Unity-5.0.2f1.pkg">Unity Editor</a>
35+
# <a href="http://download.unity3d.com/download_unity/a6d8d714de6f/UnityDownloadAssistant-5.4.0f3.dmg">Unity编辑器</a>
36+
# urlTuples = re.findall(r'<a href="(https?://[^"]*?/(Mac|Windows32|Windows64)EditorInstaller/Unity-(5\..*?)\.(pkg|exe))">Unity Editor</a>', data)
37+
urlTuples = re.findall(r'<a href="(https?://[^"]*?(UnityDownloadAssistant|EditorInstaller/Unity.*?)-(.*?)\.(pkg|dmg|exe))">Unity Editor.*?</a>', data)
38+
return urlTuples
39+
40+
osmap = {
41+
'mac' : 'Mac',
42+
'osx' : 'Mac',
43+
'win' : 'Windows',
44+
'win64' : 'Windows64',
45+
'win32' : 'Windows32',
46+
}
47+
48+
def splitByOS(urlTuples):
49+
macs, win64s, win32s = [], [], []
50+
for urlTuple in urlTuples:
51+
if urlTuple[0].find('Mac') >= 0 or urlTuple[0].find('UnityDownloadAssistant') >= 0:
52+
macs.append(urlTuple)
53+
elif urlTuple[0].find('Windows64') >= 0:
54+
win64s.append(urlTuple)
55+
elif urlTuple[0].find('Windows32') >= 0:
56+
win32s.append(urlTuple)
57+
return macs, win64s, win32s
58+
59+
def filterByVersion(urlTuples, version):
60+
if version is None:
61+
return urlTuples
62+
if version == 'last' or version == 'latest' or version == 'beta':
63+
del urlTuples[1:]
64+
return urlTuples
65+
66+
isNewst = version.endswith('+')
67+
isOldest = version.endswith('-')
68+
if isNewst or isOldest:
69+
version = version[0:-1]
70+
urlTuples = filter(lambda urlTuple: urlTuple[2].find(version) >= 0, urlTuples)
71+
if isNewst:
72+
del urlTuples[1:]
73+
elif isOldest:
74+
del urlTuples[-1:]
75+
return urlTuples
76+
77+
def filterUrlTuples(urlTuples, os, version):
78+
if len(urlTuples) == 0 :
79+
return urlTuples
80+
81+
macs, win64s, win32s = splitByOS(urlTuples)
82+
if os is not None:
83+
os = osmap[os.lower()]
84+
if os == 'Mac':
85+
win64s, win32s = [], []
86+
elif os == 'Windows64':
87+
macs, win32s = [], []
88+
elif os == 'Windows32':
89+
macs, win64s = [], []
90+
elif os == 'Windows':
91+
macs = []
92+
93+
if version is not None:
94+
macs = filterByVersion(macs, version)
95+
win64s = filterByVersion(win64s, version)
96+
win32s = filterByVersion(win32s, version)
97+
98+
urlTuples = macs
99+
urlTuples[len(urlTuples):len(urlTuples)+len(win64s)] = win64s
100+
urlTuples[len(urlTuples):len(urlTuples)+len(win32s)] = win32s
101+
return urlTuples
102+
103+
# -------------- main --------------
104+
if __name__ == '__main__':
105+
usage = "usage: %prog [options]"
106+
parser = OptionParser(usage=usage)
107+
parser.add_option(
108+
'-v', '--version', dest='version',
109+
help='filter unity version, beta last latest 5 5.3[+|-] 5.3.5')
110+
parser.add_option(
111+
'-o', '--os', dest='os',
112+
help='filter os, win[64|32] or osx or mac')
113+
parser.add_option(
114+
'-l', '--list', dest='list', action='store_true', default=False,
115+
help='show a list')
116+
(opts, args) = parser.parse_args()
117+
118+
if opts.version == 'beta':
119+
urlTuples = getBetaUrlTuples()
120+
else:
121+
urlTuples = getUrlTuples()
122+
urlTuples = filterUrlTuples(urlTuples, opts.os, opts.version)
123+
124+
if opts.list:
125+
for urlTuple in urlTuples:
126+
print urlTuple[0]
127+
elif len(urlTuples) > 0:
128+
print urlTuples[0][0]

0 commit comments

Comments
 (0)