Skip to content

Commit ef0afd0

Browse files
committed
Merge pull request #88 from RemoteTechnologiesGroup/chore/travis
Move travis ci intergration into the develop branch
2 parents 8308de8 + 3a94201 commit ef0afd0

File tree

7 files changed

+165
-14
lines changed

7 files changed

+165
-14
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,9 @@ $RECYCLE.BIN/
154154

155155
# Mac desktop service store files
156156
.DS_Store
157+
158+
# Ignore dependencies and builds
159+
src/RemoteTech2/*.dll
160+
*.zip
161+
GameData/RemoteTech2/Plugins/RemoteTech2.dll
162+
GameData/build.txt

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: objective-c # force osx machines
2+
3+
os:
4+
- osx
5+
6+
env:
7+
global:
8+
- secure: Q4UfP54tnvoioOnoQElnkUQMd4qQ/2dLLkhnSz35MiwUrraxqrixdh22EWsTmcqD8ntjPI4tt3P9N6On9+qn8D+qYpt+zX5otikfgvXdKCxGJj+q1Nv0rWq6b0P5QGo61vXFV1cH4EOONBDyAq0IbmtjtEISBhQaefFdzaAAk/Y=
9+
- secure: J/M1/WIRgP4GssMr9HS9k7Wr9XUqlo0S+olIVWvr8eY8jxxVbx+ONZbkkjKey2BvC1BRVtRXpbBe+YcPLYe7V1jG5mmm3Lc1B/x5WC54q4KKfoV53m+ARAtaHFYrJY2h4O+GLaysQoCwCG/tAt0GhJmgJgy9IojH4ojJjDOGHCE=
10+
before_install:
11+
- date -u
12+
- uname -a
13+
- export BUILDTAG=`git describe --abbrev=0 --tags`
14+
- env | sort | grep -v ZIPPASSWORD | grep -v GITHUB_TOKEN
15+
16+
install:
17+
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then echo "Should only be on OSX"; exit 1; fi
18+
- ./CI/travis.osx.install.deps.sh # it appears TRAVIS_OS_NAME is unset often, assume we're OSX if not linux
19+
20+
script:
21+
- ./build.remotetech2.sh
22+
23+
# Custom deploy
24+
after_success:
25+
- ./CI/github.build.deploy.sh

CI/github.build.deploy.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
# These should be set by Travis
4+
#TRAVIS_BUILD_NUMBER=1
5+
#TRAVIS_BRANCH=master
6+
#TRAVIS_REPO_SLUG="RemoteTechnologiesGroup/RemoteTech"
7+
#TRAVIS_COMMIT=master
8+
#GITHUB_TOKEN="Personal access token from https://github.com/settings/applications"
9+
#TRAVIS_PULL_REQUEST=false
10+
11+
VERSION="build-${TRAVIS_BRANCH}-${TRAVIS_BUILD_NUMBER}"
12+
FILENAME=$(echo "${VERSION}.zip" | tr '/' '_') # else it will fail on branches like chore/travis
13+
14+
python_parse_json() {
15+
# python errors are surpressed for when the key doesn't exist
16+
cat | python -c 'import sys,json;obj=json.load(sys.stdin);print obj[sys.argv[1]];' $1 2>/dev/null
17+
}
18+
19+
if [ -z "$GITHUB_TOKEN" ] || [ -z "$TRAVIS_REPO_SLUG" ] \
20+
|| [ -z "$TRAVIS_BUILD_NUMBER" ] || [ -z "$TRAVIS_BRANCH" ] \
21+
|| [ -z "$TRAVIS_COMMIT" ]
22+
then
23+
echo "GITHUB_TOKEN, TRAVIS_REPO_SLUG, TRAVIS_BUILD_NUMBER and TRAVIS_COMMIT must be set in order to deploy";
24+
echo "Skipping deploy for now";
25+
exit 0; # prevent build failing if unset
26+
fi
27+
28+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]
29+
then
30+
echo "This is a pull request build, it doesn't need to be released."
31+
exit 0; # prevent build fail
32+
fi
33+
34+
if [[ "$TRAVIS_BRANCH" == build* ]]
35+
then
36+
echo "We're already on a 'build branch' (or tag), don't need to deploy again";
37+
exit 0;
38+
fi
39+
40+
echo "Build ${TRAVIS_BUILD_NUMBER} from branch ${TRAVIS_BRANCH} in ${TRAVIS_REPO_SLUG}" > GameData/build.txt
41+
echo "Built from commit ${TRAVIS_COMMIT} with tag ${BUILDTAG}" >> GameData/build.txt
42+
echo "Creating ${FILENAME}"
43+
zip -r "${FILENAME}" GameData/
44+
45+
echo "Attempting to create tag ${VERSION} on ${TRAVIS_REPO_SLUG}"
46+
API_JSON=$(printf '{"tag_name": "%s","target_commitish": "%s","name": "%s","body": "Automated pre-release of branch %s build %s","draft": false,"prerelease": true}' \
47+
$VERSION $TRAVIS_COMMIT $VERSION $TRAVIS_BRANCH $TRAVIS_BUILD_NUMBER)
48+
ADDRESS=$(printf 'https://api.github.com/repos/%s/releases?access_token=%s' $TRAVIS_REPO_SLUG $GITHUB_TOKEN)
49+
50+
REPLY=$(curl --data "$API_JSON" "$ADDRESS");
51+
UPLOAD_ID=$(echo $REPLY | python_parse_json "id")
52+
ERRORS=$(echo $REPLY | python_parse_json "errors");
53+
54+
if [ -n "$ERRORS" ] || [ -z "$REPLY" ] || [ -z "$UPLOAD_ID" ]
55+
then
56+
echo "ERROR: An error occured while setting the tag";
57+
echo $REPLY;
58+
exit 1;
59+
fi
60+
61+
UPLOAD_URL="https://uploads.github.com/repos/${TRAVIS_REPO_SLUG}/releases/${UPLOAD_ID}/assets"
62+
63+
echo "Uploading ${FILENAME} to GitHub repo ${UPLOAD_ID} (tag ${VERSION} on ${TRAVIS_REPO_SLUG})"
64+
REPLY=$(curl -H "Authorization: token ${GITHUB_TOKEN}" \
65+
-H "Accept: application/vnd.github.manifold-preview" \
66+
-H "Content-Type: application/zip" \
67+
--data-binary @${FILENAME} \
68+
"${UPLOAD_URL}?name=${FILENAME}")
69+
70+
ERRORS=$(echo $REPLY | python_parse_json "errors")
71+
ASSET_ID=$(echo $REPLY | python_parse_json "id" )
72+
73+
if [ -n "$ERRORS" ] || [ -z "$REPLY" ] || [ -z "$ASSET_ID" ]
74+
then
75+
echo "ERROR: An error occured while uploading the file to GitHub";
76+
echo $REPLY;
77+
exit 1;
78+
fi
79+
80+
echo "Uploaded ${FILENAME} to ${TRAVIS_REPO_SLUG} as asset id ${ASSET_ID}"

CI/travis.osx.install.deps.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
MONO_VERSION="3.4.0"
5+
6+
echo "Installing Mono ${MONO_VERSION}"
7+
wget "http://download.mono-project.com/archive/${MONO_VERSION}/macos-10-x86/MonoFramework-MDK-${MONO_VERSION}.macos10.xamarin.x86.pkg"
8+
sudo installer -pkg "MonoFramework-MDK-${MONO_VERSION}.macos10.xamarin.x86.pkg" -target /

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
[![Build Status](https://travis-ci.org/RemoteTechnologiesGroup/RemoteTech.svg?branch=master)](https://travis-ci.org/RemoteTechnologiesGroup/RemoteTech)
2+
13
RemoteTech
24
==========
35

46
Community developed continuation of Kerbal Space Program's RemoteTech mod.
7+
Minor change to test travis pull requests.

build.remotetech2.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
SRCDIR=src/RemoteTech2
4+
5+
if [ ! -f "$SRCDIR/Assembly-CSharp-firstpass.dll" ] \
6+
|| [ ! -f "$SRCDIR/Assembly-CSharp.dll" ] \
7+
|| [ ! -f "$SRCDIR/UnityEngine.dll" ];
8+
then
9+
if [ "$TRAVIS_SECURE_ENV_VARS" = "false" ]; then
10+
# this should only happen for pull requests
11+
echo "Unable to build as the env vars have not been set. Can't decrypt the zip."
12+
exit 0; # can't decide if this should error
13+
fi
14+
15+
if [[ ! -f dlls.zip ]]; then
16+
echo "Need to get dependency .dll's"
17+
wget -O dlls.zip "https://www.dropbox.com/s/kyv25p3qn166nzp/dlls.zip?dl=1"
18+
fi
19+
20+
if [ -z "$ZIPPASSWORD" ]; then
21+
if [ "$TRAVIS" = "true" ]; then
22+
echo "Password not set, on travis and DLL's missing, can't build";
23+
exit 1;
24+
else
25+
echo "Password required to decrypt the zip";
26+
unzip dlls.zip -d src/RemoteTech2/ # this will prompt for a password
27+
fi
28+
else
29+
unzip -P "$ZIPPASSWORD" dlls.zip -d src/RemoteTech2/
30+
fi
31+
32+
rm -f dlls.zip
33+
fi
34+
35+
cd src/RemoteTech2 && xbuild
36+

src/RemoteTech2/RemoteTech2.csproj

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4-
<Import Project="C:\Program Files\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks" />
4+
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\$(MSBuildToolsVersion)\MSBuild.ExtensionPack.tasks" />
55
<PropertyGroup>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
77
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -18,7 +18,7 @@
1818
<DebugSymbols>false</DebugSymbols>
1919
<DebugType>none</DebugType>
2020
<Optimize>false</Optimize>
21-
<OutputPath>C:\Users\Sander\Desktop\KSP Dev\GameData\RemoteTech2\Plugins\</OutputPath>
21+
<OutputPath>..\..\GameData\RemoteTech2\Plugins\</OutputPath>
2222
<DefineConstants>DEBUG;TRACE</DefineConstants>
2323
<ErrorReport>prompt</ErrorReport>
2424
<WarningLevel>4</WarningLevel>
@@ -28,19 +28,19 @@
2828
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2929
<DebugType>none</DebugType>
3030
<Optimize>true</Optimize>
31-
<OutputPath>C:\Users\Sander\Desktop\KSP Dev\GameData\RemoteTech2\Plugins\</OutputPath>
31+
<OutputPath>..\..\GameData\RemoteTech2\Plugins\</OutputPath>
3232
<DefineConstants>TRACE</DefineConstants>
3333
<ErrorReport>prompt</ErrorReport>
3434
<WarningLevel>4</WarningLevel>
3535
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
3636
</PropertyGroup>
3737
<ItemGroup>
3838
<Reference Include="Assembly-CSharp">
39-
<HintPath>C:\Users\Sander\Desktop\KSP Dev\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
39+
<HintPath>Assembly-CSharp.dll</HintPath>
4040
<Private>False</Private>
4141
</Reference>
4242
<Reference Include="Assembly-CSharp-firstpass">
43-
<HintPath>C:\Users\Sander\Desktop\KSP Dev\KSP_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
43+
<HintPath>Assembly-CSharp-firstpass.dll</HintPath>
4444
<Private>False</Private>
4545
</Reference>
4646
<Reference Include="System" />
@@ -50,7 +50,7 @@
5050
<Reference Include="System.Data" />
5151
<Reference Include="System.Xml" />
5252
<Reference Include="UnityEngine">
53-
<HintPath>C:\Users\Sander\Desktop\KSP Dev\KSP_Data\Managed\UnityEngine.dll</HintPath>
53+
<HintPath>UnityEngine.dll</HintPath>
5454
<Private>False</Private>
5555
</Reference>
5656
</ItemGroup>
@@ -125,12 +125,5 @@
125125
<Target Name="BeforeBuild">
126126
</Target>
127127
<Target Name="AfterBuild">
128-
<PropertyGroup>
129-
<PathToZip>../../GameData</PathToZip>
130-
<PluginLocation>../../GameData/RemoteTech2/Plugins/</PluginLocation>
131-
<ZipDate>$([System.DateTime]::Now.ToString(`yyyy.MM.dd.HH.mm`))</ZipDate>
132-
</PropertyGroup>
133-
<Copy DestinationFolder="$(PluginLocation)" OverwriteReadOnlyFiles="True" SkipUnchangedFiles="False" SourceFiles="$(OutputPath)$(AssemblyName).dll" />
134-
<MSBuild.ExtensionPack.Compression.DNZip TaskAction="Create" CompressPath="$(PathToZip)" ZipFileName="../../dist/RemoteTech2_$(ZipDate).zip" />
135128
</Target>
136-
</Project>
129+
</Project>

0 commit comments

Comments
 (0)