.travis.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. language: php
  2. php:
  3. - '7.1'
  4. - '7.2'
  5. - '7.3'
  6. - '7.4'
  7. branches:
  8. only:
  9. - build_test
  10. notifications:
  11. email:
  12. on_success: never
  13. on_failure: always
  14. slack:
  15. secure: dowksPsxxCxGKT6nis5hUgkp6+ZDAhoqzQHF9rJnx4hx0iEygPhVBs7pKl9yL2jubYJoLs+EXwE7z1dYgDAEJh4BnfrCokCMLpFGcxVxQC/HeAUdSQ2/RtdBYR5PRT75ScaFpqM/SfXXZVtnwVXAw9Z+JC6BjQ9vmn23m51Jw4k=
  16. env:
  17. global:
  18. # Colors!
  19. - TEXTRESET=$(tput sgr0) # reset the foreground colour
  20. - RED=$(tput setaf 1)
  21. - GREEN=$(tput setaf 2)
  22. - YELLOW=$(tput setaf 3)
  23. - BLUE=$(tput setaf 4)
  24. - BOLD=$(tput bold)
  25. # User
  26. - GH_USER="getgrav"
  27. # Paths
  28. - RT_DEVTOOLS=$HOME/devtools
  29. - GOPATH="$HOME/go"
  30. - PATH="$GOPATH/bin:$PATH"
  31. # GH_TOKEN [API Key]
  32. - secure: "NR9pV7YteY9OoPmjDTQG0fDfocVu+tCeiDH1F2GFhXCu71UOIvqWXpOxp0RHkG5GIXdCFHx59yu+ZO275lbaHkbF8+4lVSVrV4RcGn+pIncvxr6iZCVW05dbAxV3H8alK+xYJRGmbyfQl5wIM49WvmuGHZjcmIloS4t/omQ3N+I="
  33. # BB_TOKEN value => "user:pass@"
  34. - secure: "einUtSEkUWy2IrqLXyVjwUU+mwaaoiOXRRVdLBpA3Zye6bZx8cm5h/5AplkPWhM/NmCJoW/MwNZHHkFhlr3mDRov5iOxVmTTYfnXB+I5lxYTSgduOLLErS7mU8hfADpVDU8bHNU44fNGD3UEiG1PD4qQBX4DMlqIFmR20mjs81k="
  35. # GH_API_USER [for curl]
  36. - secure: "AQGcX1B2NrI8ajflY4AimZDNcK2kBA3F6mbtEFQ78NkDoWhMipsQHayWXiSTzRc0YJKvQl2Y16MTwQF4VHzjTAiiZFATgA8J88vQUjIPabi/kKjqSmcLFoaAOAxStQbW6e0z2GiQ6KBMcNF1y5iUuI63xVrBvtKrYX/w5y+ako8="
  37. before_install:
  38. - export TZ=Pacific/Honolulu
  39. - echo $TRAVIS_PHP_VERSION
  40. - echo $TRAVIS_BRANCH
  41. - echo $TRAVIS_PULL_REQUEST
  42. - composer self-update
  43. - if [ $TRAVIS_BRANCH == 'develop' ] || [ $TRAVIS_PULL_REQUEST != 'false' ]; then
  44. composer install --dev --prefer-dist;
  45. fi
  46. - |
  47. if [ $TRAVIS_BRANCH != 'develop' ] && [ $TRAVIS_PHP_VERSION == "7.1" ] && [ $TRAVIS_PULL_REQUEST == "false" ]; then
  48. export TRAVIS_TAG=$(curl -H "Authorization: token ${GH_TOKEN}" --fail -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.13 bash)";
  50. go get github.com/github-release/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. - phpenv config-rm xdebug.ini
  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