2014-02-13 11:33:11 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2014-03-06 13:54:24 +08:00
|
|
|
PROJECT_ROOT="$DIR"/../..
|
|
|
|
|
2014-03-06 14:10:50 +08:00
|
|
|
COMMITTAG="[AUTO][ci skip]: updating cocos2dx_files.json"
|
|
|
|
PUSH_REPO="https://api.github.com/repos/cocos2d/cocos2d-x/pulls"
|
|
|
|
OUTPUT_FILE_PATH="${PROJECT_ROOT}/templates/cocos2dx_files.json"
|
2015-07-25 13:31:52 +08:00
|
|
|
FETCH_REMOTE_BRANCH="v3.7.1"
|
2014-03-25 17:07:15 +08:00
|
|
|
COMMIT_PATH="templates/cocos2dx_files.json"
|
2014-03-06 14:10:50 +08:00
|
|
|
|
2014-02-13 11:33:11 +08:00
|
|
|
# Exit on error
|
|
|
|
set -e
|
|
|
|
|
|
|
|
generate_cocosfiles_json()
|
|
|
|
{
|
|
|
|
echo "Updates cocos_files.json"
|
2014-03-06 14:56:22 +08:00
|
|
|
./generate-template-files.py
|
2014-02-13 11:33:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$GEN_COCOS_FILES"x != "YES"x ]; then
|
|
|
|
generate_cocosfiles_json
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2014-03-06 13:54:24 +08:00
|
|
|
pushd "$PROJECT_ROOT"
|
2014-02-13 11:33:11 +08:00
|
|
|
#Set git user for cocos2d-x repo
|
|
|
|
git config user.email ${GH_EMAIL}
|
|
|
|
git config user.name ${GH_USER}
|
|
|
|
popd
|
|
|
|
|
|
|
|
|
|
|
|
# 1. Updates cocos_files.json
|
|
|
|
generate_cocosfiles_json
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo cocos_files.json was generated successfully
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo Using "'$COMMITTAG'" in the commit messages
|
|
|
|
echo
|
|
|
|
|
|
|
|
ELAPSEDSECS=`date +%s`
|
|
|
|
echo Using "$ELAPSEDSECS" in the branch names for pseudo-uniqueness
|
|
|
|
|
|
|
|
|
|
|
|
# 2. Check if there are any files that are different from the index
|
|
|
|
|
2014-03-06 13:54:24 +08:00
|
|
|
pushd "$PROJECT_ROOT"
|
2014-02-13 11:33:11 +08:00
|
|
|
|
|
|
|
# Run status to record the output in the log
|
|
|
|
git status
|
|
|
|
|
|
|
|
echo
|
2014-03-25 16:24:08 +08:00
|
|
|
echo Comparing with origin HEAD ...
|
2014-02-13 11:33:11 +08:00
|
|
|
echo
|
|
|
|
|
2014-03-25 16:24:08 +08:00
|
|
|
git fetch origin ${FETCH_REMOTE_BRANCH}
|
|
|
|
|
2014-02-13 11:33:11 +08:00
|
|
|
# Don't exit on non-zero return value
|
|
|
|
set +e
|
2014-03-25 17:07:15 +08:00
|
|
|
git diff FETCH_HEAD --stat --exit-code ${COMMIT_PATH}
|
2014-02-13 11:33:11 +08:00
|
|
|
|
|
|
|
DIFF_RETVAL=$?
|
|
|
|
if [ $DIFF_RETVAL -eq 0 ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "No differences in cocos_files.json"
|
|
|
|
echo "Exiting with success."
|
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "Generated files differ from HEAD. Continuing."
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
set -e
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
COCOS_BRANCH=update_cocosfiles_"$ELAPSEDSECS"
|
|
|
|
|
|
|
|
pushd "${DIR}"
|
|
|
|
|
2014-03-06 13:54:24 +08:00
|
|
|
cd "${PROJECT_ROOT}"
|
2014-02-13 11:33:11 +08:00
|
|
|
git add .
|
|
|
|
git checkout -b "$COCOS_BRANCH"
|
2014-03-06 14:10:50 +08:00
|
|
|
git commit -m "$COMMITTAG"
|
2014-02-13 11:33:11 +08:00
|
|
|
#Set remotes
|
|
|
|
git remote add upstream https://${GH_USER}:${GH_PASSWORD}@github.com/${GH_USER}/cocos2d-x.git 2> /dev/null > /dev/null
|
2014-02-13 11:38:28 +08:00
|
|
|
# 4. In Cocos2D-X repo, Push the commit to cocos2d-x repository
|
2014-02-13 11:33:11 +08:00
|
|
|
echo "Pushing to Robot's repo ..."
|
|
|
|
git push -fq upstream "$COCOS_BRANCH" 2> /dev/null
|
|
|
|
|
|
|
|
|
|
|
|
# 5.
|
|
|
|
echo "Sending Pull Request to base repo ..."
|
2014-03-06 14:10:50 +08:00
|
|
|
curl --user "${GH_USER}:${GH_PASSWORD}" --request POST --data "{ \"title\": \"$COMMITTAG\", \"body\": \"\", \"head\": \"${GH_USER}:${COCOS_BRANCH}\", \"base\": \"${TRAVIS_BRANCH}\"}" "${PUSH_REPO}" 2> /dev/null > /dev/null
|
2014-02-13 11:33:11 +08:00
|
|
|
|
|
|
|
popd
|