2018-08-13 14:24:40 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-08-27 10:01:17 -04:00
|
|
|
mkdir -p vscode
|
|
|
|
cd vscode
|
|
|
|
|
|
|
|
git init -q
|
|
|
|
git remote add origin https://github.com/Microsoft/vscode.git
|
|
|
|
|
2020-09-16 14:18:02 -04:00
|
|
|
# figure out latest tag by calling MS update API
|
2021-08-03 08:43:49 -04:00
|
|
|
if [ "$INSIDER" == "1" ]; then
|
|
|
|
UPDATE_INFO=$(curl https://update.code.visualstudio.com/api/update/darwin/insider/lol)
|
2021-08-27 10:01:17 -04:00
|
|
|
export MS_COMMIT=$(echo $UPDATE_INFO | jq -r '.version')
|
|
|
|
export MS_TAG=$(echo $UPDATE_INFO | jq -r '.name')
|
|
|
|
elif [[ -z "${MS_TAG}" ]]; then
|
2021-08-03 08:43:49 -04:00
|
|
|
UPDATE_INFO=$(curl https://update.code.visualstudio.com/api/update/darwin/stable/lol)
|
2021-08-27 10:01:17 -04:00
|
|
|
export MS_COMMIT=$(echo $UPDATE_INFO | jq -r '.version')
|
|
|
|
export MS_TAG=$(echo $UPDATE_INFO | jq -r '.name')
|
2021-08-03 08:43:49 -04:00
|
|
|
else
|
2021-08-27 10:01:17 -04:00
|
|
|
tag_line=$( git ls-remote --tags --sort=-version:refname | grep "refs\/tags\/${MS_TAG}" | head -1 )
|
|
|
|
|
|
|
|
[[ "${tag_line}" =~ ^([[:alnum:]]+)[[:space:]]+refs\/tags\/([0-9]+\.[0-9]+\.[0-9]+)$ ]]
|
|
|
|
|
|
|
|
export MS_COMMIT="${BASH_REMATCH[1]}"
|
2021-08-03 08:43:49 -04:00
|
|
|
fi
|
2020-09-16 14:18:02 -04:00
|
|
|
|
2021-08-27 10:01:17 -04:00
|
|
|
echo "Got the MS tag: ${MS_TAG} version: ${MS_COMMIT}"
|
|
|
|
|
|
|
|
git fetch --depth 1 origin $MS_COMMIT
|
|
|
|
git checkout FETCH_HEAD
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
2020-10-06 00:30:07 -04:00
|
|
|
# for GH actions
|
2021-03-10 10:04:07 -05:00
|
|
|
if [[ $GITHUB_ENV ]]; then
|
2021-08-27 12:26:59 -04:00
|
|
|
echo "MS_TAG=$MS_TAG" >> $GITHUB_ENV
|
2021-08-27 10:01:17 -04:00
|
|
|
echo "MS_COMMIT=$MS_COMMIT" >> $GITHUB_ENV
|
2021-03-10 10:04:07 -05:00
|
|
|
fi
|