You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

push.sh 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # Unbreakable build
  3. function alert_user {
  4. echo "${1}"
  5. which -s growlnotify && growlnotify `basename $0` -m "${1}"
  6. }
  7. function exit_ko {
  8. alert_user "${1}"; exit 1
  9. }
  10. function exit_ok {
  11. alert_user "${1}"; exit 0
  12. }
  13. LOCATION=$(pwd)
  14. REMOTE=${1:-origin}
  15. REMOTE_URL=$(git remote show -n ${REMOTE} | awk '/Fetch/ {print $3}')
  16. BRANCH=$(git symbolic-ref -q HEAD)
  17. BRANCH=${BRANCH##refs/heads/}
  18. # Git black magic to pull rebase even with uncommited work in progress
  19. git fetch ${REMOTE}
  20. git add -A; git ls-files --deleted -z | xargs -0 -I {} git rm {}; git commit -m "wip"
  21. git rebase ${REMOTE}/${BRANCH}
  22. if [ "$?" -ne 0 ]; then
  23. git rebase --abort
  24. git log -n 1 | grep -q -c "wip" && git reset HEAD~1
  25. exit_ko "Unable to rebase. please pull or rebase and fix conflicts manually."
  26. fi
  27. git log -n 1 | grep -q -c "wip" && git reset HEAD~1
  28. # Private build
  29. rm -Rf ../privatebuild
  30. git clone --single-branch -slb "${BRANCH}" . ../privatebuild
  31. cd ../privatebuild
  32. # Build with maven
  33. set MAVEN_OPTS=-Xmx1G
  34. mvn -T4 install -Pdev -DskipSanityChecks=false
  35. if [ $? -ne 0 ]; then
  36. exit_ko "Unable to build"
  37. fi
  38. # Push
  39. git push ${REMOTE_URL} ${BRANCH}
  40. if [ $? -ne 0 ]; then
  41. exit_ko "Unable to push"
  42. fi
  43. # Update working directory
  44. cd ${LOCATION} && git fetch ${REMOTE}
  45. exit_ok "Yet another successful build!"