2019-05-16 13:41:32 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [[ "$SHOULD_BUILD" != "yes" ]]; then
|
|
|
|
echo "Will not update version JSON because we did not build"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# {
|
|
|
|
# "url": "https://az764295.vo.msecnd.net/stable/51b0b28134d51361cf996d2f0a1c698247aeabd8/VSCode-darwin-stable.zip",
|
|
|
|
# "name": "1.33.1",
|
|
|
|
# "version": "51b0b28134d51361cf996d2f0a1c698247aeabd8",
|
|
|
|
# "productVersion": "1.33.1",
|
|
|
|
# "hash": "cb4109f196d23b9d1e8646ce43145c5bb62f55a8",
|
|
|
|
# "timestamp": 1554971059007,
|
|
|
|
# "sha256hash": "ac2a1c8772501732cd5ff539a04bb4dc566b58b8528609d2b34bbf970d08cf01"
|
|
|
|
# }
|
|
|
|
|
|
|
|
# `url` is URL_BASE + filename of asset e.g.
|
2021-08-27 10:01:17 -04:00
|
|
|
# darwin: https://github.com/VSCodium/vscodium/releases/download/${MS_TAG}/VSCodium-darwin-${MS_TAG}.zip
|
|
|
|
# `name` is $MS_TAG
|
|
|
|
# `version` is $MS_COMMIT
|
|
|
|
# `productVersion` is $MS_TAG
|
2019-05-16 13:41:32 -04:00
|
|
|
# `hash` in <filename>.sha1
|
|
|
|
# `timestamp` is $(node -e 'console.log(Date.now())')
|
|
|
|
# `sha256hash` in <filename>.sha256
|
|
|
|
|
2021-08-27 10:01:17 -04:00
|
|
|
URL_BASE=https://github.com/VSCodium/vscodium/releases/download/${MS_TAG}
|
2019-05-16 13:41:32 -04:00
|
|
|
|
2019-05-17 22:47:03 -04:00
|
|
|
# to make testing on forks easier
|
2021-01-12 15:01:29 -05:00
|
|
|
VERSIONS_REPO="${GITHUB_USERNAME}/versions"
|
|
|
|
echo "Versions repo:" $VERSIONS_REPO
|
2019-05-17 22:47:03 -04:00
|
|
|
|
|
|
|
# generateJson <assetName>
|
|
|
|
# e.g. generateJson VSCodium-darwin-1.33.0.zip
|
|
|
|
generateJson() {
|
|
|
|
local assetName=$1
|
|
|
|
|
|
|
|
# generate parts
|
|
|
|
local url=${URL_BASE}/${assetName}
|
2021-08-27 10:01:17 -04:00
|
|
|
local name=$MS_TAG
|
|
|
|
local version=$MS_COMMIT
|
|
|
|
local productVersion=$MS_TAG
|
2019-05-17 22:47:03 -04:00
|
|
|
local timestamp=$(node -e 'console.log(Date.now())')
|
|
|
|
|
|
|
|
local sha1hash=$(cat ${assetName}.sha1 | awk '{ print $1 }')
|
|
|
|
local sha256hash=$(cat ${assetName}.sha256 | awk '{ print $1 }')
|
|
|
|
|
|
|
|
# check that nothing is blank (blank indicates something awry with build)
|
|
|
|
for key in url name version productVersion sha1hash timestamp sha256hash; do
|
|
|
|
if [[ "${!key}" == "" ]]; then
|
|
|
|
echo "Missing data for version update; exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# generate json
|
|
|
|
local json=$(jq \
|
|
|
|
--arg url "${url}" \
|
|
|
|
--arg name "${name}" \
|
|
|
|
--arg version "${version}" \
|
|
|
|
--arg productVersion "${productVersion}" \
|
|
|
|
--arg hash "${sha1hash}" \
|
|
|
|
--arg timestamp "${timestamp}" \
|
|
|
|
--arg sha256hash "${sha256hash}" \
|
|
|
|
'. | .url=$url | .name=$name | .version=$version | .productVersion=$productVersion | .hash=$hash | .timestamp=$timestamp | .sha256hash=$sha256hash' \
|
|
|
|
<<<'{}')
|
|
|
|
|
|
|
|
echo "$json"
|
|
|
|
}
|
|
|
|
|
|
|
|
updateLatestVersion() {
|
|
|
|
cd versions
|
|
|
|
|
|
|
|
local versionPath=$1
|
|
|
|
local json=$2
|
|
|
|
|
|
|
|
# create/update the latest.json file in the correct location
|
|
|
|
mkdir -p $versionPath
|
|
|
|
echo $json > $versionPath/latest.json
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
# init versions repo for later commiting + pushing the json file to it
|
|
|
|
# thank you https://www.vinaygopinath.me/blog/tech/commit-to-master-branch-on-github-using-travis-ci/
|
|
|
|
git clone https://github.com/${VERSIONS_REPO}.git
|
|
|
|
cd versions
|
2019-07-09 18:25:17 -04:00
|
|
|
git config user.email "vscodium-ci@not-real.com"
|
|
|
|
git config user.name "VSCodium CI"
|
2019-05-17 22:47:03 -04:00
|
|
|
git remote rm origin
|
|
|
|
git remote add origin https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${VERSIONS_REPO}.git > /dev/null 2>&1
|
|
|
|
cd ..
|
|
|
|
|
2020-09-20 17:26:06 -04:00
|
|
|
if [[ "$OS_NAME" == "osx" ]]; then
|
2019-05-16 13:41:32 -04:00
|
|
|
# zip, sha1, and sha256 files are all at top level dir
|
2021-08-27 10:01:17 -04:00
|
|
|
ASSET_NAME=VSCodium-darwin-${VSCODE_ARCH}-${MS_TAG}.zip
|
2020-12-22 23:02:22 -05:00
|
|
|
VERSION_PATH="darwin/${VSCODE_ARCH}"
|
2019-05-17 22:47:03 -04:00
|
|
|
JSON="$(generateJson ${ASSET_NAME})"
|
|
|
|
updateLatestVersion "$VERSION_PATH" "$JSON"
|
2021-01-12 15:01:29 -05:00
|
|
|
elif [[ "$OS_NAME" == "windows" ]]; then
|
2019-07-09 18:25:17 -04:00
|
|
|
# system installer
|
2021-08-27 10:01:17 -04:00
|
|
|
ASSET_NAME=VSCodiumSetup-${VSCODE_ARCH}-${MS_TAG}.exe
|
2021-01-12 15:01:29 -05:00
|
|
|
VERSION_PATH="win32/${VSCODE_ARCH}/system"
|
2019-07-09 18:25:17 -04:00
|
|
|
JSON="$(generateJson ${ASSET_NAME})"
|
|
|
|
updateLatestVersion "$VERSION_PATH" "$JSON"
|
2019-05-17 22:47:03 -04:00
|
|
|
|
|
|
|
# user installer
|
2021-08-27 10:01:17 -04:00
|
|
|
ASSET_NAME=VSCodiumUserSetup-${VSCODE_ARCH}-${MS_TAG}.exe
|
2021-01-12 15:01:29 -05:00
|
|
|
VERSION_PATH="win32/${VSCODE_ARCH}/user"
|
2019-05-19 16:16:49 -04:00
|
|
|
JSON="$(generateJson ${ASSET_NAME})"
|
2019-05-17 22:47:03 -04:00
|
|
|
updateLatestVersion "$VERSION_PATH" "$JSON"
|
|
|
|
|
|
|
|
# windows archive
|
2021-08-27 10:01:17 -04:00
|
|
|
ASSET_NAME=VSCodium-win32-${VSCODE_ARCH}-${MS_TAG}.zip
|
2021-01-12 15:01:29 -05:00
|
|
|
VERSION_PATH="win32/${VSCODE_ARCH}/archive"
|
2019-05-19 16:16:49 -04:00
|
|
|
JSON="$(generateJson ${ASSET_NAME})"
|
2019-05-17 22:47:03 -04:00
|
|
|
updateLatestVersion "$VERSION_PATH" "$JSON"
|
2021-09-08 19:38:07 -04:00
|
|
|
|
|
|
|
if [[ "${VSCODE_ARCH}" == "ia32" || "${VSCODE_ARCH}" == "x64" ]]; then
|
|
|
|
# msi
|
|
|
|
ASSET_NAME=VSCodium-${VSCODE_ARCH}-${MS_TAG}.msi
|
|
|
|
VERSION_PATH="win32/${VSCODE_ARCH}/msi"
|
|
|
|
JSON="$(generateJson ${ASSET_NAME})"
|
|
|
|
updateLatestVersion "$VERSION_PATH" "$JSON"
|
|
|
|
|
|
|
|
# updates-disabled msi
|
|
|
|
ASSET_NAME=VSCodium-${VSCODE_ARCH}-updates-disabled-${MS_TAG}.msi
|
|
|
|
VERSION_PATH="win32/${VSCODE_ARCH}/msi-updates-disabled"
|
|
|
|
JSON="$(generateJson ${ASSET_NAME})"
|
|
|
|
updateLatestVersion "$VERSION_PATH" "$JSON"
|
|
|
|
fi
|
2019-05-16 13:41:32 -04:00
|
|
|
else # linux
|
|
|
|
# update service links to tar.gz file
|
|
|
|
# see https://update.code.visualstudio.com/api/update/linux-x64/stable/VERSION
|
|
|
|
# as examples
|
2021-08-27 10:01:17 -04:00
|
|
|
ASSET_NAME=VSCodium-linux-${VSCODE_ARCH}-${MS_TAG}.tar.gz
|
2020-10-05 13:12:28 -04:00
|
|
|
VERSION_PATH="linux/${VSCODE_ARCH}"
|
2019-05-17 22:47:03 -04:00
|
|
|
JSON="$(generateJson ${ASSET_NAME})"
|
|
|
|
updateLatestVersion "$VERSION_PATH" "$JSON"
|
2019-05-16 13:41:32 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd versions
|
2019-05-17 22:47:03 -04:00
|
|
|
|
2019-05-20 12:27:22 -04:00
|
|
|
git pull origin master # in case another build just pushed
|
2019-05-17 22:47:03 -04:00
|
|
|
git add .
|
2019-05-16 13:41:32 -04:00
|
|
|
dateAndMonth=`date "+%D %T"`
|
2020-09-20 17:26:06 -04:00
|
|
|
git commit -m "CI update: $dateAndMonth (Build $GITHUB_RUN_NUMBER)"
|
2019-06-11 00:35:15 -04:00
|
|
|
if ! git push origin master --quiet; then
|
|
|
|
git pull origin master
|
|
|
|
git push origin master --quiet
|
|
|
|
fi
|
2019-05-17 22:47:03 -04:00
|
|
|
|
|
|
|
cd ..
|