2018-08-13 18:24:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-08-16 12:33:30 +00:00
|
|
|
set -e
|
|
|
|
|
2022-08-16 11:51:45 +00:00
|
|
|
# git workaround
|
|
|
|
if [[ "${CI_BUILD}" != "no" ]]; then
|
|
|
|
git config --global --add safe.directory /__w/vscodium/vscodium
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "${RELEASE_VERSION}" ]]; then
|
2022-08-29 13:13:25 +00:00
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
|
|
|
if [[ "${VSCODE_LATEST}" == "yes" ]] || [[ ! -f "insider.json" ]]; then
|
2022-09-11 11:08:41 +00:00
|
|
|
UPDATE_INFO=$( curl --silent https://update.code.visualstudio.com/api/update/darwin/insider/lol )
|
2022-08-29 13:13:25 +00:00
|
|
|
else
|
|
|
|
export MS_COMMIT=$(jq -r '.commit' insider.json)
|
|
|
|
export MS_TAG=$(jq -r '.tag' insider.json)
|
|
|
|
fi
|
|
|
|
else
|
2022-09-11 11:08:41 +00:00
|
|
|
UPDATE_INFO=$( curl --silent https://update.code.visualstudio.com/api/update/darwin/stable/lol )
|
2022-08-29 13:13:25 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "${MS_COMMIT}" ]]; then
|
|
|
|
export MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
|
|
|
|
export MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
|
2022-08-31 07:54:04 +00:00
|
|
|
|
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
|
|
|
export MS_TAG="${MS_TAG/\-insider/}"
|
|
|
|
fi
|
2022-08-29 13:13:25 +00:00
|
|
|
fi
|
|
|
|
|
2022-08-16 11:51:45 +00:00
|
|
|
date=$( date +%Y%j )
|
2022-08-29 13:13:25 +00:00
|
|
|
|
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
2022-08-31 07:54:04 +00:00
|
|
|
export RELEASE_VERSION="${MS_TAG}.${date: -5}-insider"
|
2022-08-29 13:13:25 +00:00
|
|
|
else
|
|
|
|
export RELEASE_VERSION="${MS_TAG}.${date: -5}"
|
|
|
|
fi
|
2022-08-16 11:51:45 +00:00
|
|
|
else
|
2022-08-30 11:55:17 +00:00
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
|
|
|
if [[ "${RELEASE_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+-insider$ ]];
|
|
|
|
then
|
|
|
|
MS_TAG="${BASH_REMATCH[1]}"
|
|
|
|
else
|
|
|
|
echo "Bad RELEASE_VERSION: ${RELEASE_VERSION}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${MS_TAG}" == "$(jq -r '.tag' insider.json)" ]]; then
|
|
|
|
export MS_COMMIT=$(jq -r '.commit' insider.json)
|
|
|
|
else
|
|
|
|
echo "No MS_COMMIT for ${RELEASE_VERSION}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-16 11:51:45 +00:00
|
|
|
else
|
2022-08-30 11:55:17 +00:00
|
|
|
if [[ "${RELEASE_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+$ ]];
|
|
|
|
then
|
|
|
|
MS_TAG="${BASH_REMATCH[1]}"
|
|
|
|
else
|
|
|
|
echo "Bad RELEASE_VERSION: ${RELEASE_VERSION}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-16 11:51:45 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-08-30 11:55:17 +00:00
|
|
|
echo "RELEASE_VERSION=\"${RELEASE_VERSION}\""
|
2022-08-16 11:51:45 +00:00
|
|
|
|
2021-08-27 14:01:17 +00:00
|
|
|
mkdir -p vscode
|
2022-06-08 20:03:44 +00:00
|
|
|
cd vscode || { echo "'vscode' dir not found"; exit 1; }
|
2021-08-27 14:01:17 +00:00
|
|
|
|
|
|
|
git init -q
|
|
|
|
git remote add origin https://github.com/Microsoft/vscode.git
|
|
|
|
|
2020-09-16 18:18:02 +00:00
|
|
|
# figure out latest tag by calling MS update API
|
2022-08-29 13:13:25 +00:00
|
|
|
if [[ -z "${MS_TAG}" ]]; then
|
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
2022-09-11 11:08:41 +00:00
|
|
|
UPDATE_INFO=$( curl --silent https://update.code.visualstudio.com/api/update/darwin/insider/lol )
|
2022-08-29 13:13:25 +00:00
|
|
|
else
|
2022-09-11 11:08:41 +00:00
|
|
|
UPDATE_INFO=$( curl --silent https://update.code.visualstudio.com/api/update/darwin/stable/lol )
|
2022-08-29 13:13:25 +00:00
|
|
|
fi
|
|
|
|
export MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
|
|
|
|
export MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
|
|
|
|
elif [[ -z "${MS_COMMIT}" ]]; then
|
2021-12-09 01:30:35 +00:00
|
|
|
reference=$( git ls-remote --tags | grep -x ".*refs\/tags\/${MS_TAG}" | head -1 )
|
|
|
|
|
|
|
|
if [[ -z "${reference}" ]]; then
|
|
|
|
echo "The following tag can't be found: ${MS_TAG}"
|
|
|
|
exit 1
|
|
|
|
elif [[ "${reference}" =~ ^([[:alnum:]]+)[[:space:]]+refs\/tags\/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
|
|
|
export MS_COMMIT="${BASH_REMATCH[1]}"
|
|
|
|
export MS_TAG="${BASH_REMATCH[2]}"
|
|
|
|
else
|
|
|
|
echo "The following reference can't be parsed: ${reference}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-03 12:43:49 +00:00
|
|
|
fi
|
2020-09-16 18:18:02 +00:00
|
|
|
|
2022-08-30 11:55:17 +00:00
|
|
|
echo "MS_TAG=\"${MS_TAG}\""
|
|
|
|
echo "MS_COMMIT=\"${MS_COMMIT}\""
|
2021-08-27 14:01:17 +00:00
|
|
|
|
2022-06-05 19:30:23 +00:00
|
|
|
git fetch --depth 1 origin "${MS_COMMIT}"
|
2021-08-27 14:01:17 +00:00
|
|
|
git checkout FETCH_HEAD
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
2020-10-06 04:30:07 +00:00
|
|
|
# for GH actions
|
2022-06-05 19:30:23 +00:00
|
|
|
if [[ ${GITHUB_ENV} ]]; then
|
|
|
|
echo "MS_TAG=${MS_TAG}" >> "${GITHUB_ENV}"
|
|
|
|
echo "MS_COMMIT=${MS_COMMIT}" >> "${GITHUB_ENV}"
|
2022-08-16 11:51:45 +00:00
|
|
|
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_ENV}"
|
2021-03-10 15:04:07 +00:00
|
|
|
fi
|
2022-08-16 11:51:45 +00:00
|
|
|
|
|
|
|
. version.sh
|