configure_ci_environment.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. #
  3. # Short script that is sourced in to the CI environment
  4. # in .gitlab-ci.yml
  5. #
  6. # Sets IS_PUBLIC and IS_PRIVATE based on branch type
  7. #
  8. # Tweaks .gitmodules file for private builds
  9. [ -z $CI_BUILD_REF ] && echo "This internal script should only be run by a Gitlab CI runner." && exit 1
  10. REF=$CI_BUILD_REF
  11. # Public branches are:
  12. # release branches - start with release/
  13. # release tags - look like vXX.YY or vXX.YY.ZZ with an optional dash followed by anything on the end
  14. # master branch
  15. #
  16. # These POSIX REs are equivalent to the REs in some "only:" sections of the gitlab-ci.yml file
  17. #
  18. if [[ $REF = "master" || $REF =~ ^release/v || $REF =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-|$) ]]; then
  19. export IS_PUBLIC=1
  20. else
  21. export IS_PRIVATE=1
  22. fi
  23. unset REF
  24. set -e
  25. if [[ $IS_PRIVATE ]]; then
  26. # Redirect git submodules from public github to our private gitlab server
  27. sed -i "s%https://github.com/espressif/esp32-wifi-lib%${GITLAB_SSH_SERVER}/idf/esp32-wifi-lib%" .gitmodules
  28. sed -i "s%https://github.com/espressif/esp32-bt-lib%${GITLAB_SSH_SERVER}/idf/esp32-bt-lib%" .gitmodules
  29. fi