Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: download quickstart.yaml from latest release branch(for main branch) #1074

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions hack/quick-start/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ function getLatestReleaseVersion() {
AUTH_HEADER="-H Authorization: token ${GITHUB_TOKEN}"
fi

# like "v1.2.3"
latestVersion=$(curl ${AUTH_HEADER} -s https://api.github.com/repos/devstream-io/devstream/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$latestVersion" ]; then
echo "Failed to get latest release version"
exit 1
fi
echo "Latest dtm release version: ${latestVersion}\n"
echo "Latest dtm release version: ${latestVersion}"
}

function downloadDtm() {
Expand All @@ -49,11 +50,31 @@ function downloadDtm() {
}

function downloadQuickStartConfig() {
# convert the latest version to a valid branch name
branchName=`semverToBranch $latestVersion`
if [ -z "$branchName" ]; then
echo "Failed to get branch name from version: $latestVersion"
exit 1
fi
# config file is small so we use -s to ignore the output
curl -s -o quickstart.yaml https://github.com/devstream-io/devstream/main/examples/quickstart.yaml
quickstartConfigUrl=https://github.com/devstream-io/devstream/${branchName}/examples/quickstart.yaml
echo "Downloading quickstart config file from ${quickstartConfigUrl}"
curl -s -o quickstart.yaml ${quickstartConfigUrl}
echo "quickstart.yaml downloaded completed"
}

# convert semver to branch name
# e.g. v1.2.3 -> release-1.2
# ref: https://docs.devstream.io/en/latest/development/branch-and-release/#3-correspondence-between-branch-name-and-version-number
function semverToBranch() {
semver=$1
# remove the leading "v"
semver=${semver:1}
# remove the last ".x"
semver=${semver%.*}
echo -n "release-${semver}"
}

function showDtmHelp() {
echo ""
# show dtm help and double check the download is success
Expand Down