diff --git a/CI/github.build.deploy.sh b/CI/github.build.deploy.sh index 2b19ef01b..fe27acbda 100755 --- a/CI/github.build.deploy.sh +++ b/CI/github.build.deploy.sh @@ -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 @@ -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"); diff --git a/build.remotetech2.sh b/build.remotetech2.sh index 992a6b8f2..5d537e114 100755 --- a/build.remotetech2.sh +++ b/build.remotetech2.sh @@ -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" @@ -27,3 +33,4 @@ then fi cd src/RemoteTech2 && xbuild +