11#! /bin/bash
22
33function init() {
4+ # todo customize dtm version, default is latest
45 if [ " $( uname) " == " Darwin" ]; then
56 HOST_OS=" darwin"
67 elif [ " $( uname) " == " Linux" ]; then
@@ -23,23 +24,24 @@ function init() {
2324}
2425
2526function getLatestReleaseVersion() {
26- if [ -n " ${GITHUB_TOKEN} " ]; then
27- AUTH_HEADER=" -H Authorization: token ${GITHUB_TOKEN} "
28- fi
27+ # get latest release version from aws s3
28+ STORAGE_BASE_URL=https://download.devstream.io
29+ LATEST_VERSION_FILE=" latest_version"
30+
31+ LATEST_VERSION=$( curl -fsSL ${STORAGE_BASE_URL} /${LATEST_VERSION_FILE} )
2932
30- # like "v1.2.3"
31- latestVersion=$( curl ${AUTH_HEADER} -s https://api.github.com/repos/devstream-io/devstream/releases/latest | grep ' "tag_name":' | sed -E ' s/.*"([^"]+)".*/\1/' )
32- if [ -z " $latestVersion " ]; then
33+ if [ -z " ${LATEST_VERSION} " ]; then
3334 echo " Failed to get latest release version"
3435 exit 1
3536 fi
36- echo " Latest dtm release version: ${latestVersion} "
37+
38+ echo " Got latest release version: ${LATEST_VERSION} "
3739}
3840
3941function downloadDtm() {
4042 # 1. download the release and rename it to "dtm"
4143 # 2. count the download count of the release
42- fullReleaseUrl=" https://devstream.gateway.scarf.sh/releases/ $latestVersion /dtm-$HOST_OS - $ HOST_ARCH"
44+ fullReleaseUrl=" ${STORAGE_BASE_URL} / ${LATEST_VERSION} /dtm-${ HOST_OS} - ${ HOST_ARCH} "
4345 echo " Downloading dtm from: $fullReleaseUrl "
4446 # use -L to follow redirects
4547 curl -L -o dtm $fullReleaseUrl
0 commit comments