| 
					
				 | 
			
			
				@@ -26,68 +26,123 @@ fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 URL_BASE=https://github.com/VSCodium/vscodium/releases/download/${LATEST_MS_TAG} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# to make testing on forks easier 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+if [[ "$CI_WINDOWS" == "True" ]]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  # BUILD_REPOSITORY_URI = e.g. https://github.com/VSCodium/vscodium 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  VERSIONs_REPO=$(echo ${BUILD_REPOSITORY_URI} | awk -F"/" '{ print $4 }')/versions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  # TRAVIS_REPO_SLUG = e.g. VSCodium/vscodium 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  VERSIONS_REPO=$(echo ${TRAVIS_REPO_SLUG} | awk -F"/" '{ print $1 }')/versions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# generateJson <assetName> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# e.g. generateJson VSCodium-darwin-1.33.0.zip 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+generateJson() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  local assetName=$1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  # generate parts 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  local url=${URL_BASE}/${assetName} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  local name=$LATEST_MS_TAG 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  local version=$LATEST_MS_COMMIT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  local productVersion=$LATEST_MS_TAG 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+git config user.email "travis@travis-ci.org" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+git config user.name "Travis CI" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+git remote rm origin 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+git remote add origin https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${VERSIONS_REPO}.git > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+cd .. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   # zip, sha1, and sha256 files are all at top level dir 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ASSET_PATH=. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ASSET_NAME=VSCodium-darwin-${LATEST_MS_TAG}.zip 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   VERSION_PATH="darwin" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  JSON="$(generateJson ${ASSET_NAME})" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  updateLatestVersion "$VERSION_PATH" "$JSON" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 elif [[ "$CI_WINDOWS" == "True" ]]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  # TODO: make this logic work for Windows builds too 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  # or re-implement it in PowerShell and call that from the Windows build 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  exit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  # windows update service supports user and archive types 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  # so we will run the commands twice 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  # user installer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ASSET_NAME=VSCodiumUserSetup-${BUILDARCH}-${LATEST_MS_TAG}.exe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if [[ "$BUILDARCH" == "x64" ]]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    VERSION_PATH="win32/${BUILDARCH}/user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    VERSION_PATH="win32/user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  JSON="$(generateJson ${ASSET_NAME} ${ASSET_PATH})" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  updateLatestVersion "$VERSION_PATH" "$JSON" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  # windows archive 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ASSET_NAME=VSCodium-win32-${BUILDARCH}-${LATEST_MS_TAG}.zip 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if [[ "$BUILDARCH" == "x64" ]]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    VERSION_PATH="win32/${BUILDARCH}/archive" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    VERSION_PATH="win32/archive" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  JSON="$(generateJson ${ASSET_NAME} ${ASSET_PATH})" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  updateLatestVersion "$VERSION_PATH" "$JSON" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 else # linux 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   # update service links to tar.gz file 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   # see https://update.code.visualstudio.com/api/update/linux-x64/stable/VERSION 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   # and https://update.code.visualstudio.com/api/update/linux-ia32/stable/VERSION 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   # as examples 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ASSET_PATH=. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ASSET_NAME=VSCodium-linux-${BUILDARCH}-${LATEST_MS_TAG}.tar.gz 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   VERSION_PATH="linux/${BUILDARCH}" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  JSON="$(generateJson ${ASSET_NAME})" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  updateLatestVersion "$VERSION_PATH" "$JSON" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-# generate parts 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-url=${URL_BASE}/${ASSET_NAME} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name=$LATEST_MS_TAG 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-version=$LATEST_MS_COMMIT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-productVersion=$LATEST_MS_TAG 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-sha1hash=$(cat ${ASSET_PATH}/${ASSET_NAME}.sha1 | awk '{ print $ 1 }') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-timestamp=$(node -e 'console.log(Date.now())') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-sha256hash=$(cat ${ASSET_PATH}/${ASSET_NAME}.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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-# clone down the current versions repo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-# create/update the latest.json file in the correct location 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-# commit and push (thank you https://www.vinaygopinath.me/blog/tech/commit-to-master-branch-on-github-using-travis-ci/) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-git clone https://github.com/VSCodium/versions.git 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 cd versions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-git config user.email "travis@travis-ci.org" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-git config user.name "Travis CI" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-mkdir -p $VERSION_PATH 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-echo $JSON > $VERSION_PATH/latest.json 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-git add $VERSION_PATH 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+git add . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 dateAndMonth=`date "+%D %T"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 git commit -m "Travis update: $dateAndMonth (Build $TRAVIS_BUILD_NUMBER)" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-git remote rm origin 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-git remote add origin https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/VSCodium/versions.git > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 git push origin master --quiet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+cd .. 
			 |