.travis.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. language: php
  2. php:
  3. - '7.1'
  4. - '7.2'
  5. - '7.3'
  6. branches:
  7. only:
  8. - develop
  9. - master
  10. - build_test
  11. notifications:
  12. email:
  13. on_success: never
  14. on_failure: always
  15. slack:
  16. secure: dowksPsxxCxGKT6nis5hUgkp6+ZDAhoqzQHF9rJnx4hx0iEygPhVBs7pKl9yL2jubYJoLs+EXwE7z1dYgDAEJh4BnfrCokCMLpFGcxVxQC/HeAUdSQ2/RtdBYR5PRT75ScaFpqM/SfXXZVtnwVXAw9Z+JC6BjQ9vmn23m51Jw4k=
  17. env:
  18. global:
  19. # Colors!
  20. - TEXTRESET=$(tput sgr0) # reset the foreground colour
  21. - RED=$(tput setaf 1)
  22. - GREEN=$(tput setaf 2)
  23. - YELLOW=$(tput setaf 3)
  24. - BLUE=$(tput setaf 4)
  25. - BOLD=$(tput bold)
  26. # User
  27. - GH_USER="getgrav"
  28. # Paths
  29. - RT_DEVTOOLS=$HOME/devtools
  30. - GOPATH="$HOME/go"
  31. - PATH="$GOPATH/bin:$PATH"
  32. # GH_TOKEN [API Key]
  33. - secure: "NR9pV7YteY9OoPmjDTQG0fDfocVu+tCeiDH1F2GFhXCu71UOIvqWXpOxp0RHkG5GIXdCFHx59yu+ZO275lbaHkbF8+4lVSVrV4RcGn+pIncvxr6iZCVW05dbAxV3H8alK+xYJRGmbyfQl5wIM49WvmuGHZjcmIloS4t/omQ3N+I="
  34. # BB_TOKEN value => "user:pass@"
  35. - secure: "einUtSEkUWy2IrqLXyVjwUU+mwaaoiOXRRVdLBpA3Zye6bZx8cm5h/5AplkPWhM/NmCJoW/MwNZHHkFhlr3mDRov5iOxVmTTYfnXB+I5lxYTSgduOLLErS7mU8hfADpVDU8bHNU44fNGD3UEiG1PD4qQBX4DMlqIFmR20mjs81k="
  36. # GH_API_USER [for curl]
  37. - secure: "AQGcX1B2NrI8ajflY4AimZDNcK2kBA3F6mbtEFQ78NkDoWhMipsQHayWXiSTzRc0YJKvQl2Y16MTwQF4VHzjTAiiZFATgA8J88vQUjIPabi/kKjqSmcLFoaAOAxStQbW6e0z2GiQ6KBMcNF1y5iUuI63xVrBvtKrYX/w5y+ako8="
  38. before_install:
  39. - export TZ=Pacific/Honolulu
  40. - echo $TRAVIS_PHP_VERSION
  41. - echo $TRAVIS_BRANCH
  42. - echo $TRAVIS_PULL_REQUEST
  43. - composer self-update
  44. - if [ $TRAVIS_BRANCH == 'develop' ] || [ $TRAVIS_PULL_REQUEST != 'false' ]; then
  45. composer install --dev --prefer-dist;
  46. fi
  47. - if [ $TRAVIS_BRANCH != 'develop' ] && [ $TRAVIS_PHP_VERSION == "7.1" ] && [ $TRAVIS_PULL_REQUEST == "false" ]; then
  48. export TRAVIS_TAG=$(curl --fail --user "${GH_API_USER}" -s https://api.github.com/repos/getgrav/grav/releases/latest | grep tag_name | head -n 1 | cut -d '"' -f 4);
  49. eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.8 bash)";
  50. go get github.com/aktau/github-release;
  51. git clone --quiet --depth=50 --branch=master https://${BB_TOKEN}bitbucket.org/rockettheme/grav-devtools.git $RT_DEVTOOLS &>/dev/null;
  52. if [ ! -z "$TRAVIS_TAG" ]; then
  53. cd ${RT_DEVTOOLS};
  54. ./build-grav.sh skeletons.txt;
  55. fi;
  56. fi
  57. before_script:
  58. - if [ $TRAVIS_PHP_VERSION != 'hhvm' ]; then phpenv config-rm xdebug.ini; fi
  59. script:
  60. - if [ $TRAVIS_BRANCH == 'develop' ] || [ $TRAVIS_PULL_REQUEST != 'false' ]; then
  61. vendor/bin/codecept run;
  62. fi
  63. - echo "Latest Release Tag - ${TRAVIS_TAG}"
  64. - if [ ! -z "$TRAVIS_TAG" ] && [ $TRAVIS_BRANCH != 'develop' ] && [ $TRAVIS_PHP_VERSION == "7.1" ] && [ $TRAVIS_PULL_REQUEST == "false" ]; then
  65. FILES="$RT_DEVTOOLS/grav-dist/*.zip";
  66. for file in ${FILES[@]}; do
  67. NAME=${file##*/};
  68. if [[ "$NAME" == *"-rc"* ]]; then
  69. REPO="$(echo ${NAME} | rev | cut -f 3- -d "-" | rev)";
  70. else
  71. REPO="$(echo ${NAME} | rev | cut -f 2- -d "-" | rev)";
  72. fi;
  73. if [[ $REPO == 'grav' || $REPO == 'grav-admin' || $REPO == 'grav-update' ]]; then
  74. REPO="grav";
  75. fi;
  76. API="$(curl --fail --user "${GH_API_USER}" -s https://api.github.com/repos/${GH_USER}/${REPO}/releases/latest)";
  77. ASSETS="$(echo "${API}" | node gh-assets.js)";
  78. TAG="$(echo "${API}" | grep tag_name | head -n 1 | cut -d '"' -f 4)";
  79. if [ $REPO == "grav" ]; then
  80. TAG="$TRAVIS_TAG";
  81. fi;
  82. if [ ! -z "$ASSETS" ]; then
  83. for asset in ${ASSETS[@]}; do
  84. asset_id=$(echo ${asset} | cut -d ':' -f 1);
  85. asset_name=$(echo ${asset} | cut -d ':' -f 2);
  86. if [ "${NAME}" == "${asset_name}" ]; then
  87. echo -e "\nAsset ${BOLD}${BLUE}${NAME}${TEXTRESET} already exists in ${YELLOW}${REPO}${TEXTRESET}@${BOLD}${YELLOW}${TAG}${TEXTRESET}... deleting id ${BOLD}${RED}${asset_id}${TEXTRESET}...";
  88. curl -X DELETE --fail --user "${GH_API_USER}" "https://api.github.com/repos/${GH_USER}/${REPO}/releases/assets/${asset_id}";
  89. fi;
  90. done;
  91. fi;
  92. echo "Uploading package ${BOLD}${BLUE}${NAME}${TEXTRESET} to ${YELLOW}${REPO}${TEXTRESET}@${YELLOW}${TAG}${TEXTRESET}";
  93. github-release upload --security-token $GH_TOKEN --user ${GH_USER} --repo $REPO --tag "$TAG" --name "$NAME" --file "$file";
  94. done;
  95. fi