Skip to content

Commit aafd415

Browse files
committed
Merge pull request #81 from Pezmc/chores/travis-loop-fix
Enhancements to travis release system, hopefully travis should test this merge.
2 parents d9317fc + 184d4b9 commit aafd415

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

CI/github.build.deploy.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
# These should be set by Travis
44
#TRAVIS_BUILD_NUMBER=1
5-
#TRAVIS_BRANCH=master/travis
5+
#TRAVIS_BRANCH=master
66
#TRAVIS_REPO_SLUG="RemoteTechnologiesGroup/RemoteTech"
7+
#TRAVIS_COMMIT=master
78
#GITHUB_TOKEN="Personal access token from https://github.com/settings/applications"
9+
#TRAVIS_PULL_REQUEST=false
810

911
VERSION="build-${TRAVIS_BRANCH}-${TRAVIS_BUILD_NUMBER}"
1012
FILENAME=$(echo "${VERSION}.zip" | tr '/' '_') # else it will fail on branches like chore/travis
@@ -14,19 +16,32 @@ python_parse_json() {
1416
cat | python -c 'import sys,json;obj=json.load(sys.stdin);print obj[sys.argv[1]];' $1 2>/dev/null
1517
}
1618

17-
echo "Creating ${FILENAME}"
18-
zip -r "${FILENAME}" GameData/
19-
2019
if [ -z "$GITHUB_TOKEN" ] || [ -z "$TRAVIS_REPO_SLUG" ] \
21-
|| [ -z "$TRAVIS_BUILD_NUMBER" ] || [ -z "$TRAVIS_BRANCH" ]
20+
|| [ -z "$TRAVIS_BUILD_NUMBER" ] || [ -z "$TRAVIS_BRANCH" ] \
21+
|| [ -z "$TRAVIS_COMMIT" ]
2222
then
23-
echo "GITHUB_TOKEN, TRAVIS_REPO_SLUG and TRAVIS_BUILD_NUMBER must be set in order to deploy";
23+
echo "GITHUB_TOKEN, TRAVIS_REPO_SLUG, TRAVIS_BUILD_NUMBER and TRAVIS_COMMIT must be set in order to deploy";
2424
echo "Skipping deploy for now";
2525
exit 0; # prevent build failing if unset
2626
fi
2727

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 "Creating ${FILENAME}"
41+
zip -r "${FILENAME}" GameData/
42+
2843
echo "Attempting to create tag ${VERSION} on ${TRAVIS_REPO_SLUG}"
29-
API_JSON=$(printf '{"tag_name": "%s","target_commitish": "master","name": "%s","body": "Automated pre-release build %s","draft": false,"prerelease": true}' $VERSION $VERSION $VERSION)
44+
API_JSON=$(printf '{"tag_name": "%s","target_commitish": "%s","name": "%s","body": "Automated pre-release of version %s","draft": false,"prerelease": true}' $VERSION $TRAVIS_COMMIT $VERSION $VERSION)
3045
ADDRESS=$(printf 'https://api.github.com/repos/%s/releases?access_token=%s' $TRAVIS_REPO_SLUG $GITHUB_TOKEN)
3146

3247
REPLY=$(curl --data "$API_JSON" "$ADDRESS");

build.remotetech2.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ if [ ! -f "$SRCDIR/Assembly-CSharp-firstpass.dll" ] \
66
|| [ ! -f "$SRCDIR/Assembly-CSharp.dll" ] \
77
|| [ ! -f "$SRCDIR/UnityEngine.dll" ];
88
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+
915
if [[ ! -f dlls.zip ]]; then
1016
echo "Need to get dependency .dll's"
1117
wget -O dlls.zip "https://www.dropbox.com/s/kyv25p3qn166nzp/dlls.zip?dl=1"
@@ -27,3 +33,4 @@ then
2733
fi
2834

2935
cd src/RemoteTech2 && xbuild
36+

0 commit comments

Comments
 (0)