2023-07-20 14:25:13 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# shellcheck disable=SC2129
|
2018-08-13 14:24:40 -04:00
|
|
|
|
2022-08-16 08:33:30 -04:00
|
|
|
set -e
|
|
|
|
|
2022-08-16 07:51:45 -04:00
|
|
|
# git workaround
|
|
|
|
if [[ "${CI_BUILD}" != "no" ]]; then
|
2022-10-06 16:15:41 -04:00
|
|
|
git config --global --add safe.directory "/__w/$( echo "${GITHUB_REPOSITORY}" | awk '{print tolower($0)}' )"
|
2022-08-16 07:51:45 -04:00
|
|
|
fi
|
|
|
|
|
2023-12-17 12:13:34 -05:00
|
|
|
if [[ -n "${PULL_REQUEST_ID}" ]]; then
|
2023-12-17 12:42:23 -05:00
|
|
|
BRANCH_NAME=$( git rev-parse --abbrev-ref HEAD )
|
|
|
|
|
2023-12-17 13:41:35 -05:00
|
|
|
git config --global user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com"
|
|
|
|
git config --global user.name "${GITHUB_USERNAME} CI"
|
2023-12-17 13:15:12 -05:00
|
|
|
git fetch --unshallow
|
2023-12-17 12:13:34 -05:00
|
|
|
git fetch origin "pull/${PULL_REQUEST_ID}/head"
|
|
|
|
git checkout FETCH_HEAD
|
2023-12-17 13:41:35 -05:00
|
|
|
git merge --no-edit "origin/${BRANCH_NAME}"
|
2023-12-17 12:13:34 -05:00
|
|
|
fi
|
|
|
|
|
2022-08-16 07:51:45 -04:00
|
|
|
if [[ -z "${RELEASE_VERSION}" ]]; then
|
2023-11-15 11:31:04 -05:00
|
|
|
if [[ "${VSCODE_LATEST}" == "yes" ]] || [[ ! -f "${VSCODE_QUALITY}.json" ]]; then
|
2024-02-22 09:28:20 -05:00
|
|
|
echo "Retrieve lastest version"
|
2023-11-15 11:31:04 -05:00
|
|
|
UPDATE_INFO=$( curl --silent --fail "https://update.code.visualstudio.com/api/update/darwin/${VSCODE_QUALITY}/0000000000000000000000000000000000000000" )
|
2022-08-29 09:13:25 -04:00
|
|
|
else
|
2024-02-22 09:28:20 -05:00
|
|
|
echo "Get version from ${VSCODE_QUALITY}.json"
|
2023-11-15 11:31:04 -05:00
|
|
|
MS_COMMIT=$( jq -r '.commit' "${VSCODE_QUALITY}.json" )
|
|
|
|
MS_TAG=$( jq -r '.tag' "${VSCODE_QUALITY}.json" )
|
2022-08-29 09:13:25 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "${MS_COMMIT}" ]]; then
|
2023-07-20 14:25:13 -04:00
|
|
|
MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
|
|
|
|
MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
|
2022-08-31 03:54:04 -04:00
|
|
|
|
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
2023-07-20 14:25:13 -04:00
|
|
|
MS_TAG="${MS_TAG/\-insider/}"
|
2022-08-31 03:54:04 -04:00
|
|
|
fi
|
2022-08-29 09:13:25 -04:00
|
|
|
fi
|
|
|
|
|
2022-08-16 07:51:45 -04:00
|
|
|
date=$( date +%Y%j )
|
2022-08-29 09:13:25 -04:00
|
|
|
|
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
2023-07-20 14:25:13 -04:00
|
|
|
RELEASE_VERSION="${MS_TAG}.${date: -5}-insider"
|
2022-08-29 09:13:25 -04:00
|
|
|
else
|
2023-07-20 14:25:13 -04:00
|
|
|
RELEASE_VERSION="${MS_TAG}.${date: -5}"
|
2022-08-29 09:13:25 -04:00
|
|
|
fi
|
2022-08-16 07:51:45 -04:00
|
|
|
else
|
2022-08-30 07:55:17 -04: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
|
2023-07-18 15:57:50 -04:00
|
|
|
echo "Error: Bad RELEASE_VERSION: ${RELEASE_VERSION}"
|
2022-08-30 07:55:17 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-16 07:51:45 -04:00
|
|
|
else
|
2022-08-30 07:55:17 -04:00
|
|
|
if [[ "${RELEASE_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+$ ]];
|
|
|
|
then
|
|
|
|
MS_TAG="${BASH_REMATCH[1]}"
|
|
|
|
else
|
2023-07-18 15:57:50 -04:00
|
|
|
echo "Error: Bad RELEASE_VERSION: ${RELEASE_VERSION}"
|
2022-08-30 07:55:17 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-16 07:51:45 -04:00
|
|
|
fi
|
2023-11-15 11:31:04 -05:00
|
|
|
|
|
|
|
if [[ "${MS_TAG}" == "$( jq -r '.tag' "${VSCODE_QUALITY}".json )" ]]; then
|
|
|
|
MS_COMMIT=$( jq -r '.commit' "${VSCODE_QUALITY}".json )
|
|
|
|
else
|
|
|
|
echo "Error: No MS_COMMIT for ${RELEASE_VERSION}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-16 07:51:45 -04:00
|
|
|
fi
|
|
|
|
|
2022-08-30 07:55:17 -04:00
|
|
|
echo "RELEASE_VERSION=\"${RELEASE_VERSION}\""
|
2022-08-16 07:51:45 -04:00
|
|
|
|
2021-08-27 10:01:17 -04:00
|
|
|
mkdir -p vscode
|
2022-06-08 16:03:44 -04:00
|
|
|
cd vscode || { echo "'vscode' dir not found"; exit 1; }
|
2021-08-27 10:01:17 -04:00
|
|
|
|
|
|
|
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
|
2022-08-29 09:13:25 -04:00
|
|
|
if [[ -z "${MS_TAG}" ]]; then
|
2023-11-15 11:31:04 -05:00
|
|
|
UPDATE_INFO=$( curl --silent --fail "https://update.code.visualstudio.com/api/update/darwin/${VSCODE_QUALITY}/0000000000000000000000000000000000000000" )
|
2023-07-20 14:25:13 -04:00
|
|
|
MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
|
|
|
|
MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
|
2022-08-29 09:13:25 -04:00
|
|
|
elif [[ -z "${MS_COMMIT}" ]]; then
|
2022-10-02 04:39:39 -04:00
|
|
|
REFERENCE=$( git ls-remote --tags | grep -x ".*refs\/tags\/${MS_TAG}" | head -1 )
|
2021-12-08 20:30:35 -05:00
|
|
|
|
2022-10-02 04:39:39 -04:00
|
|
|
if [[ -z "${REFERENCE}" ]]; then
|
2023-07-18 15:57:50 -04:00
|
|
|
echo "Error: The following tag can't be found: ${MS_TAG}"
|
2021-12-08 20:30:35 -05:00
|
|
|
exit 1
|
2022-10-02 04:39:39 -04:00
|
|
|
elif [[ "${REFERENCE}" =~ ^([[:alnum:]]+)[[:space:]]+refs\/tags\/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
2023-07-20 14:25:13 -04:00
|
|
|
MS_COMMIT="${BASH_REMATCH[1]}"
|
|
|
|
MS_TAG="${BASH_REMATCH[2]}"
|
2021-12-08 20:30:35 -05:00
|
|
|
else
|
2023-07-18 15:57:50 -04:00
|
|
|
echo "Error: The following reference can't be parsed: ${REFERENCE}"
|
2021-12-08 20:30:35 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-03 08:43:49 -04:00
|
|
|
fi
|
2020-09-16 14:18:02 -04:00
|
|
|
|
2022-08-30 07:55:17 -04:00
|
|
|
echo "MS_TAG=\"${MS_TAG}\""
|
|
|
|
echo "MS_COMMIT=\"${MS_COMMIT}\""
|
2021-08-27 10:01:17 -04:00
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
git fetch --depth 1 origin "${MS_COMMIT}"
|
2021-08-27 10:01:17 -04:00
|
|
|
git checkout FETCH_HEAD
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
2020-10-06 00:30:07 -04:00
|
|
|
# for GH actions
|
2022-10-16 17:55:34 -04:00
|
|
|
if [[ "${GITHUB_ENV}" ]]; then
|
2022-06-05 15:30:23 -04:00
|
|
|
echo "MS_TAG=${MS_TAG}" >> "${GITHUB_ENV}"
|
|
|
|
echo "MS_COMMIT=${MS_COMMIT}" >> "${GITHUB_ENV}"
|
2022-08-16 07:51:45 -04:00
|
|
|
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_ENV}"
|
2021-03-10 10:04:07 -05:00
|
|
|
fi
|
2023-07-20 14:25:13 -04:00
|
|
|
|
|
|
|
export MS_TAG
|
|
|
|
export MS_COMMIT
|
2023-09-03 08:59:11 -04:00
|
|
|
export RELEASE_VERSION
|