@@ -0,0 +1,154 @@
|
#!/usr/bin/env bash
|
|
# USE AT YOUR OWN RISK ALSO DOUBLE CHECK EVERYTHING!!!
|
|
re='^.+$'
|
r_re="^[0-9]+.[0-9]+$"
|
v_re="^[0-9]+$"
|
y_re="^[Yy]$"
|
BETA=false
|
deb_url=""
|
beta_url=""
|
compass_url="https://downloads.mongodb.com/compass"
|
MODE=""
|
|
if [ $# -eq 4 ] && ( [ "$4" = "verify" ] || [ "$4" = "create" ] || [ "$4" = "publish" ] ); then
|
MODE="$4"
|
else
|
echo "usage: release.sh <major_minor> <channel> <patch> <command>"
|
echo "";
|
echo "---------";
|
echo "examples:";
|
echo ""
|
echo "To release 1.20.1 when the current stable version is 1.20.0:"
|
echo " scripts/release.sh 1.20 stable create";
|
echo " scripts/release.sh 1.20 stable verify";
|
echo " scripts/release.sh 1.20 stable publish";
|
echo "";
|
echo "command is one of:";
|
echo " create # basically npm version and push";
|
echo " verify # makes sure evergreen job triggered by 'create' worked correctly";
|
echo " publish # makes the release available on mongodb.com";
|
exit 1
|
fi
|
if ! [[ "$1" =~ $r_re ]]; then
|
echo "Need to set a valid release, <semver.major>.<semver.minor>"
|
exit 1
|
fi
|
if ! [[ "$3" =~ $v_re ]]; then
|
echo "Need to set a valid version, <semver.patch>"
|
exit 1
|
fi
|
|
version=""
|
previous_version=""
|
oc=`expr $3 - 1`
|
branch="$1-releases"
|
|
if [ "$2" = "beta" ]; then
|
version="$1.0-beta.$3"
|
beta=true
|
compass_url="https://downloads.mongodb.com/compass/beta"
|
beta_url="-beta"
|
deb_url="_$1.0~beta.$3"
|
previous_version="beta.$oc"
|
new="beta.$3"
|
elif [ "$2" = "stable" ]; then
|
version="$1.$3"
|
deb_url="_$version"
|
previous_version="$1.$oc"
|
new="$version"
|
else
|
echo "Need to specify 'beta' or 'stable'"
|
exit 1
|
fi
|
|
create() {
|
read -p "Create '$version' on '$branch'. Y/N? " doit
|
echo
|
|
if [[ $doit =~ $y_re ]]; then
|
env -i
|
git checkout $branch;
|
git pull origin $branch --rebase;
|
[[ $beta = true ]] && npm version $version --no-git-tag-version || npm version patch --no-git-tag-version
|
npm install
|
git add package.json
|
git add package-lock.json
|
git commit -m $version
|
git tag -a $version -m $version
|
|
echo;
|
echo "##############################################################";
|
echo "# OK does this look right? #";
|
echo "##############################################################"; echo;
|
git show
|
echo; read -p "?????????????????????????? r u sure ?????????????????????????? " isok
|
echo; echo
|
if [[ $isok =~ $y_re ]]; then
|
git push origin $branch
|
git push --tags
|
echo "Pushed. Once it's finished building, run this again with 'verify' to test the download urls"
|
if [ "$2" = "beta" ]; then
|
echo " evergreen: https://evergreen.mongodb.com/waterfall/10gen-compass-testing";
|
elif [ "$2" = "stable" ]; then
|
echo " evergreen: open https://evergreen.mongodb.com/waterfall/10gen-compass-stable";
|
fi
|
else
|
git reset --hard HEAD^
|
git tag -d $version
|
echo; echo "fix it!"
|
exit 1
|
fi
|
else
|
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
|
fi
|
}
|
|
verify_url() {
|
echo "$testing $1"
|
if ! [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then
|
echo "Error: $1 failed validation"
|
exit 1;
|
fi
|
}
|
|
verify() {
|
echo "verifying URLs"
|
flavors=("" "-community" "-readonly" "-isolated")
|
for f in "${flavors[@]}"; do
|
verify_url "$compass_url/mongodb-compass$f-$version-darwin-x64.dmg"
|
verify_url "$compass_url/mongodb-compass$f-$version-win32-x64.msi"
|
verify_url "$compass_url/mongodb-compass${f}${beta_url}${deb_url}_amd64.deb"
|
verify_url "$compass_url/mongodb-compass${f}${beta_url}-$version.x86_64.rpm"
|
done
|
echo "All good!";
|
echo "If nothing failed can run this again with the 'publish' command to make it live on mongodb.com"
|
}
|
|
replace() {
|
aws s3 cp s3://info-mongodb-com/com-download-center/compass.json compass.json
|
sed -e s/${previous_version}/${new}/g compass.json > new_compass.json
|
colordiff compass.json new_compass.json
|
read -p "Look right?! " yeah
|
if [[ $yeah =~ $y_re ]]; then
|
echo "publishing..."
|
aws s3 cp new_compass.json s3://info-mongodb-com/com-download-center/compass.json --profile downloadcenter
|
else
|
echo "exiting..."
|
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
|
fi
|
}
|
|
publish() {
|
read -p "Replacing $previous_version with $new, right?!?! " yaok
|
if [[ $yaok =~ $y_re ]]; then
|
replace
|
else
|
read -p "OK, what's the string it should be replacing?" i_previous_version
|
previous_version=$i_previous_version
|
publish
|
fi
|
}
|
|
$MODE
|