2019-02-23 10:23:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
cd "$(dirname "$0")/../../" || {
|
|
|
|
echo "Failed to enter base dir"
|
|
|
|
exit 1
|
|
|
|
}
|
2020-05-03 20:02:18 +00:00
|
|
|
source ./scripts/travis/properties.sh
|
2021-03-22 16:17:34 +00:00
|
|
|
source ./scripts/helper.sh
|
2020-04-02 23:14:37 +00:00
|
|
|
|
2019-02-23 10:23:02 +00:00
|
|
|
if [[ -z "${GIT_AUTHTOKEN}" ]]; then
|
2021-03-22 16:17:34 +00:00
|
|
|
echo "GIT_AUTHTOKEN isn't set. Don't deploying build!"
|
|
|
|
exit 0
|
2019-02-23 10:23:02 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
git_release_executable="/tmp/git-release"
|
|
|
|
install_git_release() {
|
|
|
|
if [[ -x "${git_release_executable}" ]]; then
|
|
|
|
# File already available. No need to install it.
|
|
|
|
return 0
|
|
|
|
fi
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
if [[ ! -f ${git_release_executable} ]]; then
|
|
|
|
echo "Downloading github-release-linux (1.2.4)"
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
if [[ -f /tmp/git-release.gz ]]; then
|
|
|
|
rm /tmp/git-release.gz
|
2020-05-03 20:03:57 +00:00
|
|
|
fi
|
2021-03-22 16:17:34 +00:00
|
|
|
wget https://github.com/tfausak/github-release/releases/download/1.2.4/github-release-linux.gz -O /tmp/git-release.gz -q
|
|
|
|
[[ $? -eq 0 ]] || {
|
|
|
|
echo "Failed to download github-release-linux"
|
|
|
|
exit 1
|
|
|
|
}
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
gunzip /tmp/git-release.gz
|
|
|
|
_exit_code=$?
|
|
|
|
[[ $_exit_code -eq 0 ]] || {
|
|
|
|
echo "Failed to unzip github-release-linux"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
chmod +x /tmp/git-release
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
echo "Download of github-release-linux (1.2.4) finished"
|
|
|
|
else
|
|
|
|
chmod +x ${git_release_executable}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -x ${git_release_executable} ]]; then
|
|
|
|
echo "git-release isn't executable"
|
2020-05-03 20:03:57 +00:00
|
|
|
exit 1
|
2021-03-22 16:17:34 +00:00
|
|
|
fi
|
2020-05-03 20:03:57 +00:00
|
|
|
}
|
2021-03-22 16:17:34 +00:00
|
|
|
install_git_release
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
git_versions_tag=$(git_version "short-tag")
|
|
|
|
echo "Deploying $git_versions_tag ($(git_version "long-tag")) to GitHub."
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
echo "Generating release tag"
|
|
|
|
${git_release_executable} release \
|
|
|
|
--repo "TeaWeb" \
|
|
|
|
--owner "TeaSpeak" \
|
|
|
|
--token "${GIT_AUTHTOKEN}" \
|
|
|
|
--title "Travis auto build $git_versions_tag" \
|
|
|
|
--tag "$git_versions_tag" \
|
|
|
|
--description "This is a auto build release from travis"
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
[[ $? -eq 0 ]] || {
|
|
|
|
echo "Failed to generate git release"
|
|
|
|
exit 1
|
|
|
|
}
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
upload_package() {
|
|
|
|
local package_file
|
|
|
|
package_file=$(find_release_package "web" "$1")
|
|
|
|
if [[ $? -eq 0 ]]; then
|
|
|
|
echo "Uploading $1 package ($package_file)"
|
|
|
|
${git_release_executable} upload \
|
|
|
|
--repo "TeaWeb" \
|
|
|
|
--owner "TeaSpeak" \
|
|
|
|
--token "${GIT_AUTHTOKEN}" \
|
|
|
|
--tag "$git_versions_tag" \
|
|
|
|
--file "$package_file" \
|
|
|
|
--name "$(basename "$package_file")"
|
2020-05-03 20:03:57 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
echo "Successfully uploaded $1 package"
|
|
|
|
else
|
|
|
|
echo "Skipping $1 package upload: $package_file"
|
|
|
|
fi
|
|
|
|
}
|
2019-02-23 10:33:12 +00:00
|
|
|
|
2021-03-22 16:17:34 +00:00
|
|
|
upload_package "development"
|
|
|
|
upload_package "release"
|
|
|
|
exit 0
|