2019-02-23 10:23:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-05-03 20:02:18 +00:00
|
|
|
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
|
|
|
|
source ./scripts/travis/properties.sh
|
2020-04-02 23:14:37 +00:00
|
|
|
|
2019-02-23 10:23:02 +00:00
|
|
|
if [[ -z "${GIT_AUTHTOKEN}" ]]; then
|
2020-04-08 10:46:13 +00:00
|
|
|
echo "GIT_AUTHTOKEN isn't set. Don't deploying build!"
|
|
|
|
exit 0
|
2019-02-23 10:23:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
GIT_COMMIT_SHORT=$(git rev-parse --short HEAD)
|
|
|
|
GIT_COMMIT_LONG=$(git rev-parse HEAD)
|
|
|
|
echo "Deploying $GIT_COMMIT_SHORT ($GIT_COMMIT_LONG) to github."
|
|
|
|
|
2020-05-03 20:03:57 +00:00
|
|
|
GIT_RELEASE_EXECUTABLE="/tmp/git-release"
|
|
|
|
if [[ ! -x ${GIT_RELEASE_EXECUTABLE} ]]; then
|
|
|
|
if [[ ! -f ${GIT_RELEASE_EXECUTABLE} ]]; then
|
|
|
|
echo "Downloading github-release-linux (1.2.4)"
|
|
|
|
|
|
|
|
if [[ -f /tmp/git-release.gz ]]; then
|
|
|
|
rm /tmp/git-release.gz
|
|
|
|
fi
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
|
2019-02-23 10:23:02 +00:00
|
|
|
echo "Generating release"
|
2020-05-03 20:03:57 +00:00
|
|
|
${GIT_RELEASE_EXECUTABLE} release \
|
|
|
|
--repo "TeaWeb" \
|
|
|
|
--owner "TeaSpeak" \
|
|
|
|
--token "${GIT_AUTHTOKEN}" \
|
|
|
|
--title "Travis autobuild ${GIT_COMMIT_SHORT}" \
|
|
|
|
--tag "${GIT_COMMIT_SHORT}" \
|
|
|
|
--description "This is a autobuild release from travis"
|
|
|
|
[[ $? -eq 0 ]] || {
|
|
|
|
echo "Failed to generate git release"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Uploading release files"
|
|
|
|
folders=("${LOG_FILE}" "${PACKAGES_DIRECTORY}")
|
|
|
|
uploaded_files=()
|
|
|
|
failed_files=()
|
|
|
|
|
|
|
|
for folder in "${folders[@]}"; do
|
|
|
|
echo "Scanning folder $folder"
|
|
|
|
if [[ ! -d ${folder} ]]; then
|
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
|
|
|
|
for file in ${folder}*; do
|
|
|
|
if [[ -d ${file} ]]; then
|
|
|
|
echo " Skipping directory `basename $file` ($file)"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo " Found entry `basename $file` ($file). Uploading file.";
|
|
|
|
|
|
|
|
${GIT_RELEASE_EXECUTABLE} upload \
|
|
|
|
--repo "TeaWeb" \
|
|
|
|
--owner "TeaSpeak" \
|
|
|
|
--token "${GIT_AUTHTOKEN}" \
|
|
|
|
--tag "${GIT_COMMIT_SHORT}" \
|
|
|
|
--file "$file" \
|
|
|
|
--name "`basename $file`"
|
|
|
|
|
|
|
|
[[ $? -eq 0 ]] && {
|
|
|
|
echo " Uploaded.";
|
|
|
|
uploaded_files+="$file"
|
|
|
|
} || {
|
|
|
|
echo "Failed to generate git release"
|
|
|
|
failed_files+="$file"
|
|
|
|
}
|
|
|
|
done
|
|
|
|
done
|
2019-02-23 10:33:12 +00:00
|
|
|
|
2019-02-23 10:38:59 +00:00
|
|
|
echo "Successfully uploaded ${#uploaded_files[@]} files. ${#failed_files[@]} uploads failed."
|
|
|
|
exit 0
|