Skip to content

Commit

Permalink
Merge pull request #81 from Pezmc/chores/travis-loop-fix
Browse files Browse the repository at this point in the history
Enhancements to travis release system, hopefully travis should test this merge.
  • Loading branch information
Pezmc committed Jun 2, 2014
2 parents d9317fc + 184d4b9 commit aafd415
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
29 changes: 22 additions & 7 deletions CI/github.build.deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

# These should be set by Travis
#TRAVIS_BUILD_NUMBER=1
#TRAVIS_BRANCH=master/travis
#TRAVIS_BRANCH=master
#TRAVIS_REPO_SLUG="RemoteTechnologiesGroup/RemoteTech"
#TRAVIS_COMMIT=master
#GITHUB_TOKEN="Personal access token from https://github.com/settings/applications"
#TRAVIS_PULL_REQUEST=false

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

echo "Creating ${FILENAME}"
zip -r "${FILENAME}" GameData/

if [ -z "$GITHUB_TOKEN" ] || [ -z "$TRAVIS_REPO_SLUG" ] \
|| [ -z "$TRAVIS_BUILD_NUMBER" ] || [ -z "$TRAVIS_BRANCH" ]
|| [ -z "$TRAVIS_BUILD_NUMBER" ] || [ -z "$TRAVIS_BRANCH" ] \
|| [ -z "$TRAVIS_COMMIT" ]
then
echo "GITHUB_TOKEN, TRAVIS_REPO_SLUG and TRAVIS_BUILD_NUMBER must be set in order to deploy";
echo "GITHUB_TOKEN, TRAVIS_REPO_SLUG, TRAVIS_BUILD_NUMBER and TRAVIS_COMMIT must be set in order to deploy";
echo "Skipping deploy for now";
exit 0; # prevent build failing if unset
fi

if [ "$TRAVIS_PULL_REQUEST" != "false" ]
then
echo "This is a pull request build, it doesn't need to be released."
exit 0; # prevent build fail
fi

if [[ "$TRAVIS_BRANCH" == build* ]]
then
echo "We're already on a 'build branch' (or tag), don't need to deploy again";
exit 0;
fi

echo "Creating ${FILENAME}"
zip -r "${FILENAME}" GameData/

echo "Attempting to create tag ${VERSION} on ${TRAVIS_REPO_SLUG}"
API_JSON=$(printf '{"tag_name": "%s","target_commitish": "master","name": "%s","body": "Automated pre-release build %s","draft": false,"prerelease": true}' $VERSION $VERSION $VERSION)
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)
ADDRESS=$(printf 'https://api.github.com/repos/%s/releases?access_token=%s' $TRAVIS_REPO_SLUG $GITHUB_TOKEN)

REPLY=$(curl --data "$API_JSON" "$ADDRESS");
Expand Down
7 changes: 7 additions & 0 deletions build.remotetech2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ if [ ! -f "$SRCDIR/Assembly-CSharp-firstpass.dll" ] \
|| [ ! -f "$SRCDIR/Assembly-CSharp.dll" ] \
|| [ ! -f "$SRCDIR/UnityEngine.dll" ];
then
if [ "$TRAVIS_SECURE_ENV_VARS" = "false" ]; then
# this should only happen for pull requests
echo "Unable to build as the env vars have not been set. Can't decrypt the zip."
exit 0; # can't decide if this should error
fi

if [[ ! -f dlls.zip ]]; then
echo "Need to get dependency .dll's"
wget -O dlls.zip "https://www.dropbox.com/s/kyv25p3qn166nzp/dlls.zip?dl=1"
Expand All @@ -27,3 +33,4 @@ then
fi

cd src/RemoteTech2 && xbuild

0 comments on commit aafd415

Please sign in to comment.