get_repo.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. set -e
  3. # git workaround
  4. if [[ "${CI_BUILD}" != "no" ]]; then
  5. git config --global --add safe.directory /__w/vscodium/vscodium
  6. fi
  7. if [[ -z "${RELEASE_VERSION}" ]]; then
  8. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  9. if [[ "${VSCODE_LATEST}" == "yes" ]] || [[ ! -f "insider.json" ]]; then
  10. UPDATE_INFO=$( curl https://update.code.visualstudio.com/api/update/darwin/insider/lol )
  11. else
  12. export MS_COMMIT=$(jq -r '.commit' insider.json)
  13. export MS_TAG=$(jq -r '.tag' insider.json)
  14. fi
  15. else
  16. UPDATE_INFO=$( curl https://update.code.visualstudio.com/api/update/darwin/stable/lol )
  17. fi
  18. if [[ -z "${MS_COMMIT}" ]]; then
  19. export MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
  20. export MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
  21. fi
  22. date=$( date +%Y%j )
  23. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  24. export RELEASE_VERSION="${MS_TAG/\-insider/}.${date: -5}-insider"
  25. else
  26. export RELEASE_VERSION="${MS_TAG}.${date: -5}"
  27. fi
  28. else
  29. if [[ "${RELEASE_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+$ ]];
  30. then
  31. MS_TAG="${BASH_REMATCH[1]}"
  32. else
  33. echo "Bad RELEASE_VERSION: ${RELEASE_VERSION}"
  34. exit 1
  35. fi
  36. fi
  37. echo "Release version: ${RELEASE_VERSION}"
  38. mkdir -p vscode
  39. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  40. git init -q
  41. git remote add origin https://github.com/Microsoft/vscode.git
  42. # figure out latest tag by calling MS update API
  43. if [[ -z "${MS_TAG}" ]]; then
  44. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  45. UPDATE_INFO=$( curl https://update.code.visualstudio.com/api/update/darwin/insider/lol )
  46. else
  47. UPDATE_INFO=$( curl https://update.code.visualstudio.com/api/update/darwin/stable/lol )
  48. fi
  49. export MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
  50. export MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
  51. elif [[ -z "${MS_COMMIT}" ]]; then
  52. reference=$( git ls-remote --tags | grep -x ".*refs\/tags\/${MS_TAG}" | head -1 )
  53. if [[ -z "${reference}" ]]; then
  54. echo "The following tag can't be found: ${MS_TAG}"
  55. exit 1
  56. elif [[ "${reference}" =~ ^([[:alnum:]]+)[[:space:]]+refs\/tags\/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
  57. export MS_COMMIT="${BASH_REMATCH[1]}"
  58. export MS_TAG="${BASH_REMATCH[2]}"
  59. else
  60. echo "The following reference can't be parsed: ${reference}"
  61. exit 1
  62. fi
  63. fi
  64. echo "Got the MS tag: ${MS_TAG} version: ${MS_COMMIT}"
  65. git fetch --depth 1 origin "${MS_COMMIT}"
  66. git checkout FETCH_HEAD
  67. cd ..
  68. # for GH actions
  69. if [[ ${GITHUB_ENV} ]]; then
  70. echo "MS_TAG=${MS_TAG}" >> "${GITHUB_ENV}"
  71. echo "MS_COMMIT=${MS_COMMIT}" >> "${GITHUB_ENV}"
  72. echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_ENV}"
  73. fi
  74. . version.sh