Added DockerHub image deploy automatisation

canary
WolverinDEV 2020-05-03 22:02:18 +02:00
parent ee673b1ac2
commit 43a73d27a0
7 changed files with 93 additions and 90 deletions

View File

@ -13,6 +13,7 @@ before_install:
- chmod +x ./scripts/travis/build.sh
- chmod +x ./scripts/travis/deploy_dev_server.sh
- chmod +x ./scripts/travis/deploy_github.sh
- chmod +x ./scripts/travis/deploy_docker.sh
stages:
- compile
@ -30,9 +31,22 @@ deploy:
skip_cleanup: true
on:
branch: develop
- provider: script
cleanup: false
skip_cleanup: true
script: "bash scripts/travis/deploy_docker.sh development"
on:
branch: develop
- provider: script
cleanup: false
skip_cleanup: true
script: "bash scripts/travis/deploy_github.sh"
on:
branch: master
- provider: script
cleanup: false
skip_cleanup: true
script: "bash scripts/travis/deploy_docker.sh release"
on:
branch: master

View File

@ -2,6 +2,7 @@
* **03.05.20**
- Splitup the file transfer & management part
- Added the ability to register a custom file transfer provider (required for the native client)
- Added DockerHub image deploy automatisation
* **25.04.20**
- Fixed missing channel tree update on talk power change

View File

@ -1,7 +1,8 @@
#!/bin/bash
LOG_FILE="auto-build/logs/build.log"
PACKAGES_DIRECTORY="auto-build/packages/"
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
source ./scripts/travis/properties.sh
build_verbose=0
build_release=1
build_debug=0

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash
PACKAGES_DIRECTORY="auto-build/packages/"
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
source ./scripts/travis/properties.sh
if [[ -z "${SSH_KEY}" ]]; then
echo "Missing environment variable SSH_KEY. Please set it before using this script!"
exit 1
@ -12,7 +14,6 @@ chmod 600 /tmp/sftp_key
echo "Failed to write SSH key"
exit 1
}
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
file=$(find "$PACKAGES_DIRECTORY" -maxdepth 1 -name "TeaWeb-release*.zip" -print)
[[ $(echo "$file" | wc -l) -ne 1 ]] && {
@ -26,16 +27,19 @@ file=$(find "$PACKAGES_DIRECTORY" -maxdepth 1 -name "TeaWeb-release*.zip" -print
#TeaSpeak-Travis-Web
# ssh -oStrictHostKeyChecking=no $h TeaSpeak-Travis-Web@dev.web.teaspeak.de
ssh -oStrictHostKeyChecking=no -oIdentitiesOnly=yes -i /tmp/sftp_key TeaSpeak-Travis-Web@dev.web.teaspeak.de rm "tmp-upload/*.zip" # Cleanup the old files
[[ $? -ne 0 ]] && {
echo "Failed to delete the old .zip files"
_exit_code=$?
[[ $_exit_code -ne 0 ]] && {
echo "Failed to delete the old .zip files ($_exit_code)"
}
filename="TeaWeb-Release-$(git rev-parse --short HEAD).zip"
sftp -oStrictHostKeyChecking=no -oIdentitiesOnly=yes -i /tmp/sftp_key TeaSpeak-Travis-Web@dev.web.teaspeak.de << EOF
put $file tmp-upload/$filename
EOF
[[ $? -ne 0 ]] && {
echo "Failed to upload the .zip file"
_exit_code=$?
[[ $_exit_code -ne 0 ]] && {
echo "Failed to upload the .zip file ($_exit_code)"
exit 1
}
ssh -oStrictHostKeyChecking=no -oIdentitiesOnly=yes -i /tmp/sftp_key TeaSpeak-Travis-Web@dev.web.teaspeak.de "./unpack.sh tmp-upload/$filename"
exit $?

View File

@ -0,0 +1,59 @@
#!/usr/bin/env bash
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
source ./scripts/travis/properties.sh
git_rev=$(git rev-parse --short HEAD)
[[ ! "$git_rev" =~ [a-z0-9]{6} ]] && {
echo "Failed to parse git rev. Received: '$git_rev'."
exit 1
}
if [[ "$1" == "release" ]]; then
echo "Releasing $git_rev as release"
rolling_tag="latest"
elif [[ "$1" == "development" ]]; then
echo "Releasing $git_rev as beta release"
rolling_tag="beta"
else
echo "Invalid release mode"
exit 1
fi
zip_file=$(find "$PACKAGES_DIRECTORY" -maxdepth 1 -name "TeaWeb-release*.zip" -print)
[[ $(echo "$zip_file" | wc -l) -ne 1 ]] && {
echo "Invalid .zip file count (Expected 1 but got $(echo "$zip_file" | wc -l)): ${zip_file[*]}"
exit 1
}
[[ ! -e "$zip_file" ]] && {
echo "File ($zip_file) does not exists"
exit 1
}
git clone https://github.com/TeaSpeak/TeaDocker.git auto-build/teadocker || {
echo "Failed to clone the TeaDocker project"
exit 1
}
docker build -f auto-build/teadocker/web/travis.Dockerfile --build-arg WEB_VERSION="$git_rev" --build-arg WEB_ZIP="$zip_file" -t teaspeak/web:"$rolling_tag" auto-build/teadocker/web || {
echo "Failed to build dockerfile"
exit 1
}
docker tag teaspeak/web:latest teaspeak/web:"$git_rev" || {
echo "Failed to tag docker release"
exit 1
}
docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_TOKEN" || {
echo "Failed to login to docker hub"
exit 1
}
docker push teaspeak/web || {
echo "Failed to push new teaspeak/web tags"
exit 1
}
docker logout # &> /dev/null
exit 0

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
PACKAGES_DIRECTORY="auto-build/packages/"
LOG_FILE="auto-build/logs/build.log"
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
source ./scripts/travis/properties.sh
if [[ -z "${GIT_AUTHTOKEN}" ]]; then
echo "GIT_AUTHTOKEN isn't set. Don't deploying build!"
@ -12,87 +12,7 @@ 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."
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; }
echo "Generating release"
${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
echo "Successfully uploaded ${#uploaded_files[@]} files. ${#failed_files[@]} uploads failed."
exit 0

View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
LOG_FILE="auto-build/logs/build.log"
PACKAGES_DIRECTORY="auto-build/packages/"