Updated the script helpers
This commit is contained in:
parent
084dd4cb63
commit
e5bedb0c44
14 changed files with 251 additions and 248 deletions
|
@ -4,6 +4,7 @@
|
||||||
"description": "Welcome here! This repository is created with two reasons:\n 1. People can bring their own ideas and follow their implementation\n 2. People can see TeaSpeak Web client progress and avoid creating repetitive issues all the time.",
|
"description": "Welcome here! This repository is created with two reasons:\n 1. People can bring their own ideas and follow their implementation\n 2. People can see TeaSpeak Web client progress and avoid creating repetitive issues all the time.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile-project-base": "tsc -p tsbaseconfig.json",
|
"compile-project-base": "tsc -p tsbaseconfig.json",
|
||||||
|
"compile-tr-gen": "tsc -p tools/trgen/tsconfig.json",
|
||||||
"trgen": "node tools/trgen/index.js",
|
"trgen": "node tools/trgen/index.js",
|
||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
"compile-scss": "sass loader/css/index.scss:loader/css/index.css",
|
"compile-scss": "sass loader/css/index.scss:loader/css/index.css",
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "$(dirname "$0")/resolve_commands.sh"
|
|
||||||
cd "$(dirname "$0")/../" || { echo "Failed to enter the base directory"; exit 1; }
|
cd "$(dirname "$0")/../" || { echo "Failed to enter the base directory"; exit 1; }
|
||||||
|
|
||||||
|
|
||||||
if [[ $# -lt 2 ]]; then
|
if [[ $# -lt 2 ]]; then
|
||||||
echo "Invalid argument count!"
|
echo "Invalid argument count!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -41,7 +39,7 @@ if [[ $_exit_code -ne 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Generating required build tooks"
|
echo "Generating required build hooks"
|
||||||
chmod +x ./tools/build_trgen.sh
|
chmod +x ./tools/build_trgen.sh
|
||||||
./tools/build_trgen.sh; _exit_code=$?
|
./tools/build_trgen.sh; _exit_code=$?
|
||||||
if [[ $_exit_code -ne 0 ]]; then
|
if [[ $_exit_code -ne 0 ]]; then
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
BASEDIR=$(dirname "$0")
|
BASEDIR=$(dirname "$0")
|
||||||
# shellcheck disable=SC1090
|
|
||||||
source "${BASEDIR}/resolve_commands.sh"
|
|
||||||
cd "$BASEDIR/../" || { echo "Failed to enter parent directory!"; exit 1; }
|
cd "$BASEDIR/../" || { echo "Failed to enter parent directory!"; exit 1; }
|
||||||
|
|
||||||
#Shared
|
#Shared
|
||||||
|
|
|
@ -35,7 +35,7 @@ function cleanup_files() {
|
||||||
for file in "${files[@]}"
|
for file in "${files[@]}"
|
||||||
do :
|
do :
|
||||||
echo " - $file"
|
echo " - $file"
|
||||||
rm ${file}
|
rm "${file}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,107 +2,52 @@
|
||||||
|
|
||||||
# Example usage: ./scripts/deploy_ui_files.sh http://dev.clientapi.teaspeak.de/api.php test 1.1.0
|
# Example usage: ./scripts/deploy_ui_files.sh http://dev.clientapi.teaspeak.de/api.php test 1.1.0
|
||||||
|
|
||||||
TMP_FILE_NAME="TeaSpeakUI.tar.gz"
|
cd "$(dirname "$0")" || { echo "failed to enter base directory"; exit 1; }
|
||||||
TMP_DIR_NAME="tmp"
|
source "./helper.sh"
|
||||||
|
|
||||||
cd "$(dirname "$0")/../" || { echo "failed to enter base directory"; exit 1; }
|
|
||||||
|
|
||||||
if [[ "$#" -ne 3 ]]; then
|
if [[ "$#" -ne 3 ]]; then
|
||||||
echo "Illegal number of parameters (url | channel | required version)"
|
echo "Illegal number of parameters (url | channel | required version)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d client-api/environment/ui-files/ ]]; then
|
|
||||||
echo "Missing UI Files"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if [[ "${teaclient_deploy_secret}" == "" ]]; then
|
if [[ "${teaclient_deploy_secret}" == "" ]]; then
|
||||||
echo "Missing deploy secret!"
|
echo "Missing deploy secret!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -e "${TMP_FILE_NAME}" ]]; then
|
package_file=$(find_release_package "client" "release")
|
||||||
echo "Temp file already exists!"
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "Deleting it!"
|
echo "$package_file"
|
||||||
|
|
||||||
if ! rm ${TMP_FILE_NAME}; then
|
|
||||||
echo "Failed to delete file"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
GIT_HASH=$(git rev-parse --verify --short HEAD)
|
|
||||||
APPLICATION_VERSION=$(< package.json python -c "import sys, json; print(json.load(sys.stdin)['version'])")
|
|
||||||
echo "Git hash ${GIT_HASH} on version ${APPLICATION_VERSION} on channel $2"
|
|
||||||
|
|
||||||
#Packaging the app
|
|
||||||
cd client-api/environment/ui-files/ || {
|
|
||||||
echo "Missing UI files directory"
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
|
||||||
if [[ -e ${TMP_DIR_NAME} ]]; then
|
|
||||||
if ! rm -r ${TMP_DIR_NAME}; then
|
|
||||||
echo "Failed to remove temporary directory!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
cp -rL raw ${TMP_DIR_NAME}
|
|
||||||
|
|
||||||
while IFS= read -r -d '' file
|
git_hash=$(git_version "short-tag")
|
||||||
do
|
application_version=$(project_version)
|
||||||
echo "Evaluating php file $file"
|
echo "Deploying $package_file."
|
||||||
__cur_dir=$(pwd)
|
echo "Hash: ${git_hash}, Version: ${application_version}, Target channel: $2."
|
||||||
cd "$(dirname "${file}")" || { echo "Failed to enter php file directory"; exit 1; }
|
|
||||||
php_result=$(php "$(basename "${file}")" 2> /dev/null)
|
|
||||||
CODE=$?
|
|
||||||
if [[ ${CODE} -ne 0 ]]; then
|
|
||||||
echo "Failed to evaluate php file $file!"
|
|
||||||
echo "Return code $CODE"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "${__cur_dir}" || { echo "failed to enter original dir"; exit 1; }
|
upload_result=$(curl \
|
||||||
echo "${php_result}" > "${file::-4}.html"
|
|
||||||
done < <(find "${TMP_DIR_NAME}" -name '*.php' -print0)
|
|
||||||
|
|
||||||
cd ${TMP_DIR_NAME} || { echo "failed to enter the temp dir"; exit 1; }
|
|
||||||
tar chvzf ${TMP_FILE_NAME} ./*; _exit_code=$?
|
|
||||||
if [[ $_exit_code -ne 0 ]]; then
|
|
||||||
echo "Failed to pack file ($_exit_code)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
mv ${TMP_FILE_NAME} ../../../../
|
|
||||||
cd ../
|
|
||||||
rm -r ${TMP_DIR_NAME}
|
|
||||||
cd ../../../
|
|
||||||
|
|
||||||
RESP=$(curl \
|
|
||||||
-k \
|
-k \
|
||||||
-X POST \
|
-X POST \
|
||||||
-F "required_client=$3" \
|
-F "required_client=$3" \
|
||||||
-F "type=deploy-ui-build" \
|
-F "type=deploy-ui-build" \
|
||||||
-F "channel=$2" \
|
-F "channel=$2" \
|
||||||
-F "version=$APPLICATION_VERSION" \
|
-F "version=$application_version" \
|
||||||
-F "git_ref=$GIT_HASH" \
|
-F "git_ref=$git_hash" \
|
||||||
-F "secret=${teaclient_deploy_secret}" \
|
-F "secret=${teaclient_deploy_secret}" \
|
||||||
-F "file=@$(pwd)/TeaSpeakUI.tar.gz" \
|
-F "file=@$package_file" \
|
||||||
"$1"
|
"$1"
|
||||||
)
|
)
|
||||||
echo "$RESP"
|
|
||||||
SUCCESS=$(echo "${RESP}" | python -c "import sys, json; print(json.load(sys.stdin)['success'])")
|
|
||||||
|
|
||||||
if [[ ! "${SUCCESS}" == "True" ]]; then
|
echo "Server upload result: $upload_result"
|
||||||
ERROR=$(echo "${RESP}" | python -c "import sys, json; print(json.load(sys.stdin)['error'])" 2>/dev/null); _exit_code=$?
|
success=$(echo "${upload_result}" | python -c "import sys, json; print(json.load(sys.stdin)['success'])")
|
||||||
if [[ $_exit_code -ne 0 ]]; then
|
|
||||||
ERROR=$(echo "${RESP}" | python -c "import sys, json; print(json.load(sys.stdin)['msg'])" 2>/dev/null)
|
|
||||||
fi
|
|
||||||
echo "Failed to deploy build!"
|
|
||||||
echo "${ERROR}"
|
|
||||||
|
|
||||||
rm ${TMP_FILE_NAME}
|
if [[ ! "${success}" == "True" ]]; then
|
||||||
|
error_message=$(echo "${upload_result}" | python -c "import sys, json; print(json.load(sys.stdin)['msg'])" 2>/dev/null);
|
||||||
|
echo "Failed to deploy build: ${error_message}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
else
|
||||||
|
echo "Build successfully deployed!"
|
||||||
echo "Build deployed!"
|
exit 0
|
||||||
|
fi
|
|
@ -1,26 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
response=$(git diff-index HEAD -- . ':!package-lock.json' ':!vendor/')
|
|
||||||
if [[ "$response" != "" ]]; then
|
|
||||||
if [[ "$1" == "sort-tag" ]]; then
|
|
||||||
echo "0000000"
|
|
||||||
fi
|
|
||||||
if [[ "$1" == "name" ]]; then
|
|
||||||
echo "custom build"
|
|
||||||
fi
|
|
||||||
if [[ "$1" == "file-name" ]]; then
|
|
||||||
echo "custom"
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
if [[ "$1" == "sort-tag" ]]; then
|
|
||||||
git rev-parse --short HEAD
|
|
||||||
fi
|
|
||||||
if [[ "$1" == "name" ]]; then
|
|
||||||
git rev-parse --short HEAD
|
|
||||||
fi
|
|
||||||
if [[ "$1" == "file-name" ]]; then
|
|
||||||
git rev-parse --short HEAD
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
fi
|
|
124
scripts/helper.sh
Normal file
124
scripts/helper.sh
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
build_package_directory="dist-package"
|
||||||
|
|
||||||
|
# Get the projects absolute directory
|
||||||
|
project_directory() {
|
||||||
|
realpath "$(dirname "$(pwd)/${BASH_SOURCE[0]}")/.."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the project version specified within the package.json file
|
||||||
|
project_version() {
|
||||||
|
< "$(project_directory)/package.json" python -c "import sys, json; print(json.load(sys.stdin)['version'])"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the absolute path to the target release package
|
||||||
|
# Parameters:
|
||||||
|
# 1. The build target
|
||||||
|
# Values: "client" | "web"
|
||||||
|
# 2. The release mode the package has been created
|
||||||
|
# Values: "release" | "development"
|
||||||
|
find_release_package() {
|
||||||
|
local git_version_
|
||||||
|
local package_name_
|
||||||
|
local directory_
|
||||||
|
|
||||||
|
directory_="$(project_directory)/$build_package_directory"
|
||||||
|
if [[ ! -d "$directory_" ]]; then
|
||||||
|
echo "Missing package directory $directory_. May you haven't yet build a package."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git_version_="$(git_version "short-tag")"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "We're in a development state and have a dirty work tree. Can't find release packages."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
package_name_="$(release_package_name "$1" "$2")"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "Failed to generate target package name: $package_name_"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$directory_/$package_name_" ]]; then
|
||||||
|
echo "Missing target package at $directory_/$package_name_ (git version: $git_version_, target: $1, release mode: $2)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$directory_/$package_name_"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generate the target build package name
|
||||||
|
# Parameters:
|
||||||
|
# 1. The build target
|
||||||
|
# Values: "client" | "web"
|
||||||
|
# 2. The release mode the package has been created
|
||||||
|
# Values: "release" | "development"
|
||||||
|
release_package_name() {
|
||||||
|
local prefix_
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"client")
|
||||||
|
prefix_="TeaClient"
|
||||||
|
;;
|
||||||
|
"web")
|
||||||
|
prefix_="TeaWeb"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "invalid package mode"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
"release" | "development")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "invalid package mode"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# This must line up with the package name generated within the webpack config!
|
||||||
|
echo "${prefix_}-$2-$(git_version "short-tag").zip"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the current working tree git version.
|
||||||
|
# If the working tree is dirty (modified) the function returns 1.
|
||||||
|
# Possible modes (first parameter):
|
||||||
|
# short-tag: Returns a 6 digit git rev
|
||||||
|
# long-tag: The full git revision hash
|
||||||
|
#
|
||||||
|
# Influential environment variables:
|
||||||
|
# ignore_dirty_worktree: If set to 1 it ignores if the worktree is dirty
|
||||||
|
git_version() {
|
||||||
|
response=$(git diff-index HEAD -- "$(project_directory)" ':!package-lock.json' ':!vendor/')
|
||||||
|
if [[ -z "$response" || "${ignore_dirty_worktree:=0}" -eq 1 ]]; then
|
||||||
|
case "$1" in
|
||||||
|
"short-tag" | "name" | "file-name")
|
||||||
|
git rev-parse --short HEAD
|
||||||
|
;;
|
||||||
|
"long-tag")
|
||||||
|
git rev-parse HEAD
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "unknown type"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
# We're in development
|
||||||
|
case "$1" in
|
||||||
|
"short-tag" | "name" | "file-name" | "long-tag")
|
||||||
|
echo "0000000"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "unknown type"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
|
@ -1,28 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
function execute_tsc() {
|
|
||||||
# shellcheck disable=SC2068
|
|
||||||
execute_npm_command tsc $@
|
|
||||||
}
|
|
||||||
|
|
||||||
function execute_npm_command() {
|
|
||||||
command_name=$1
|
|
||||||
command_variable="command_$command_name"
|
|
||||||
#echo "Variable names $command_variable"
|
|
||||||
|
|
||||||
if [[ "${!command_variable}" == "" ]]; then
|
|
||||||
node_bin=$(npm bin)
|
|
||||||
#echo "Node root ${node_bin}"
|
|
||||||
|
|
||||||
if [[ ! -e "${node_bin}/${command_name}" ]]; then
|
|
||||||
echo "Could not find \"$command_name\" command"
|
|
||||||
echo "May type npm install"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
eval "${command_variable}=\"${node_bin}/${command_name}\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Arguments: ${@:2}"
|
|
||||||
${!command_variable} ${@:2}
|
|
||||||
}
|
|
|
@ -60,11 +60,11 @@ function parse_arguments() {
|
||||||
function execute() {
|
function execute() {
|
||||||
time_begin=$(date +%s%N)
|
time_begin=$(date +%s%N)
|
||||||
|
|
||||||
echo "> Executing step: $1" >> ${LOG_FILE}
|
echo "> Executing step: $1" >> "${LOG_FILE}"
|
||||||
echo -e "\e[32m> Executing step: $1\e[0m"
|
echo -e "\e[32m> Executing step: $1\e[0m"
|
||||||
#Execute the command
|
#Execute the command
|
||||||
for command in "${@:3}"; do
|
for command in "${@:3}"; do
|
||||||
echo "$> $command" >> ${LOG_FILE}
|
echo "$> $command" >> "${LOG_FILE}"
|
||||||
if [[ ${build_verbose} -gt 0 ]]; then
|
if [[ ${build_verbose} -gt 0 ]]; then
|
||||||
echo "$> $command"
|
echo "$> $command"
|
||||||
fi
|
fi
|
||||||
|
@ -72,18 +72,18 @@ function execute() {
|
||||||
error=""
|
error=""
|
||||||
if [[ ${build_verbose} -gt 0 ]]; then
|
if [[ ${build_verbose} -gt 0 ]]; then
|
||||||
if [[ -f ${LOG_FILE}.tmp ]]; then
|
if [[ -f ${LOG_FILE}.tmp ]]; then
|
||||||
rm ${LOG_FILE}.tmp
|
rm "${LOG_FILE}.tmp"
|
||||||
fi
|
fi
|
||||||
${command} |& tee ${LOG_FILE}.tmp | grep -E '^[^(/\S*/libstdc++.so\S*: no version information available)].*'
|
${command} |& tee "${LOG_FILE}.tmp" | grep -E '^[^(/\S*/libstdc++.so\S*: no version information available)].*'
|
||||||
|
|
||||||
error_code=${PIPESTATUS[0]}
|
error_code=${PIPESTATUS[0]}
|
||||||
error=$(cat ${LOG_FILE}.tmp)
|
error=$(cat "${LOG_FILE}.tmp")
|
||||||
cat ${LOG_FILE}.tmp >> ${LOG_FILE}
|
cat "${LOG_FILE}.tmp" >> "${LOG_FILE}"
|
||||||
rm ${LOG_FILE}.tmp
|
rm "${LOG_FILE}.tmp"
|
||||||
else
|
else
|
||||||
error=$(${command} 2>&1)
|
error=$(${command} 2>&1)
|
||||||
error_code=$?
|
error_code=$?
|
||||||
echo "$error" >> ${LOG_FILE}
|
echo "$error" >> "${LOG_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,9 @@
|
||||||
|
|
||||||
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
|
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
|
||||||
source ./scripts/travis/properties.sh
|
source ./scripts/travis/properties.sh
|
||||||
|
source ./scripts/helper.sh
|
||||||
|
|
||||||
git_rev=$(git rev-parse --short HEAD)
|
git_rev=$(git_version "short-tag")
|
||||||
[[ ! "$git_rev" =~ [a-z0-9]{6} ]] && {
|
|
||||||
echo "Failed to parse git rev. Received: '$git_rev'."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "$1" == "release" ]]; then
|
if [[ "$1" == "release" ]]; then
|
||||||
echo "Releasing $git_rev as release"
|
echo "Releasing $git_rev as release"
|
||||||
rolling_tag="latest"
|
rolling_tag="latest"
|
||||||
|
@ -20,6 +16,7 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# FIXME: This dosn't work anymore
|
||||||
zip_file=$(find "$PACKAGES_DIRECTORY" -maxdepth 1 -name "TeaWeb-release*.zip" -print)
|
zip_file=$(find "$PACKAGES_DIRECTORY" -maxdepth 1 -name "TeaWeb-release*.zip" -print)
|
||||||
[[ $(echo "$zip_file" | wc -l) -ne 1 ]] && {
|
[[ $(echo "$zip_file" | wc -l) -ne 1 ]] && {
|
||||||
echo "Invalid .zip file count (Expected 1 but got $(echo "$zip_file" | wc -l)): ${zip_file[*]}"
|
echo "Invalid .zip file count (Expected 1 but got $(echo "$zip_file" | wc -l)): ${zip_file[*]}"
|
||||||
|
|
|
@ -1,98 +1,92 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
|
cd "$(dirname "$0")/../../" || {
|
||||||
|
echo "Failed to enter base dir"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
source ./scripts/travis/properties.sh
|
source ./scripts/travis/properties.sh
|
||||||
|
source ./scripts/helper.sh
|
||||||
|
|
||||||
if [[ -z "${GIT_AUTHTOKEN}" ]]; then
|
if [[ -z "${GIT_AUTHTOKEN}" ]]; then
|
||||||
echo "GIT_AUTHTOKEN isn't set. Don't deploying build!"
|
echo "GIT_AUTHTOKEN isn't set. Don't deploying build!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GIT_COMMIT_SHORT=$(git rev-parse --short HEAD)
|
git_release_executable="/tmp/git-release"
|
||||||
GIT_COMMIT_LONG=$(git rev-parse HEAD)
|
install_git_release() {
|
||||||
echo "Deploying $GIT_COMMIT_SHORT ($GIT_COMMIT_LONG) to github."
|
if [[ -x "${git_release_executable}" ]]; then
|
||||||
|
# File already available. No need to install it.
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
GIT_RELEASE_EXECUTABLE="/tmp/git-release"
|
if [[ ! -f ${git_release_executable} ]]; then
|
||||||
if [[ ! -x ${GIT_RELEASE_EXECUTABLE} ]]; then
|
echo "Downloading github-release-linux (1.2.4)"
|
||||||
if [[ ! -f ${GIT_RELEASE_EXECUTABLE} ]]; then
|
|
||||||
echo "Downloading github-release-linux (1.2.4)"
|
|
||||||
|
|
||||||
if [[ -f /tmp/git-release.gz ]]; then
|
if [[ -f /tmp/git-release.gz ]]; then
|
||||||
rm /tmp/git-release.gz
|
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
|
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
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -x ${GIT_RELEASE_EXECUTABLE} ]]; then
|
gunzip /tmp/git-release.gz
|
||||||
echo "git-release isn't executable"
|
_exit_code=$?
|
||||||
exit 1
|
[[ $_exit_code -eq 0 ]] || {
|
||||||
fi
|
echo "Failed to unzip github-release-linux"
|
||||||
fi
|
exit 1
|
||||||
|
}
|
||||||
|
chmod +x /tmp/git-release
|
||||||
|
|
||||||
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
|
echo "Download of github-release-linux (1.2.4) finished"
|
||||||
echo "Generating release"
|
else
|
||||||
${GIT_RELEASE_EXECUTABLE} release \
|
chmod +x ${git_release_executable}
|
||||||
--repo "TeaWeb" \
|
fi
|
||||||
--owner "TeaSpeak" \
|
|
||||||
--token "${GIT_AUTHTOKEN}" \
|
if [[ ! -x ${git_release_executable} ]]; then
|
||||||
--title "Travis autobuild ${GIT_COMMIT_SHORT}" \
|
echo "git-release isn't executable"
|
||||||
--tag "${GIT_COMMIT_SHORT}" \
|
|
||||||
--description "This is a autobuild release from travis"
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
echo "Failed to generate git release"
|
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
install_git_release
|
||||||
|
|
||||||
|
git_versions_tag=$(git_version "short-tag")
|
||||||
|
echo "Deploying $git_versions_tag ($(git_version "long-tag")) to GitHub."
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
[[ $? -eq 0 ]] || {
|
||||||
|
echo "Failed to generate git release"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Uploading release files"
|
upload_package() {
|
||||||
folders=("${LOG_FILE}" "${PACKAGES_DIRECTORY}")
|
local package_file
|
||||||
uploaded_files=()
|
package_file=$(find_release_package "web" "$1")
|
||||||
failed_files=()
|
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")"
|
||||||
|
|
||||||
for folder in "${folders[@]}"; do
|
echo "Successfully uploaded $1 package"
|
||||||
echo "Scanning folder $folder"
|
else
|
||||||
if [[ ! -d ${folder} ]]; then
|
echo "Skipping $1 package upload: $package_file"
|
||||||
continue;
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
for file in ${folder}*; do
|
upload_package "development"
|
||||||
if [[ -d ${file} ]]; then
|
upload_package "release"
|
||||||
echo " Skipping directory `basename $file` ($file)"
|
exit 0
|
||||||
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
|
|
||||||
|
|
|
@ -5,8 +5,12 @@ if [[ -z "$1" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$(dirname "$0")/../../" || { echo "Failed to enter base dir"; exit 1; }
|
cd "$(dirname "$0")/../../" || {
|
||||||
|
echo "Failed to enter base dir"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
source ./scripts/travis/properties.sh
|
source ./scripts/travis/properties.sh
|
||||||
|
source ./scripts/helper.sh
|
||||||
|
|
||||||
if [[ -z "${SSH_KEY}" ]]; then
|
if [[ -z "${SSH_KEY}" ]]; then
|
||||||
echo "Missing environment variable SSH_KEY. Please set it before using this script!"
|
echo "Missing environment variable SSH_KEY. Please set it before using this script!"
|
||||||
|
@ -20,31 +24,28 @@ chmod 600 /tmp/sftp_key
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
file=$(find "$PACKAGES_DIRECTORY" -maxdepth 1 -name "TeaWeb-release*.zip" -print)
|
|
||||||
[[ $(echo "$file" | wc -l) -ne 1 ]] && {
|
package_file=$(find_release_package "web" "release")
|
||||||
echo "Invalid release file count (Expected 1 but got $(echo "$file" | wc -l)): ${file[*]}"
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "$package_file"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
[[ ! -e "$file" ]] && {
|
|
||||||
echo "File ($file) does not exists"
|
upload_name=$(basename "$package_file")
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
#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@web.teaspeak.dev rm "tmp-upload/*.zip" # Cleanup the old files
|
ssh -oStrictHostKeyChecking=no -oIdentitiesOnly=yes -i /tmp/sftp_key TeaSpeak-Travis-Web@web.teaspeak.dev rm "tmp-upload/*.zip" # Cleanup the old files
|
||||||
_exit_code=$?
|
_exit_code=$?
|
||||||
[[ $_exit_code -ne 0 ]] && {
|
[[ $_exit_code -ne 0 ]] && {
|
||||||
echo "Failed to delete the old .zip files ($_exit_code)"
|
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@web.teaspeak.dev << EOF
|
sftp -oStrictHostKeyChecking=no -oIdentitiesOnly=yes -i /tmp/sftp_key TeaSpeak-Travis-Web@web.teaspeak.dev << EOF
|
||||||
put $file tmp-upload/$filename
|
put $package_file tmp-upload/$upload_name
|
||||||
EOF
|
EOF
|
||||||
_exit_code=$?
|
_exit_code=$?
|
||||||
[[ $_exit_code -ne 0 ]] && {
|
[[ $_exit_code -ne 0 ]] && {
|
||||||
echo "Failed to upload the .zip file ($_exit_code)"
|
echo "Failed to upload the .zip file ($_exit_code)"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
ssh -oStrictHostKeyChecking=no -oIdentitiesOnly=yes -i /tmp/sftp_key TeaSpeak-Travis-Web@web.teaspeak.dev "./unpack.sh $1 tmp-upload/$filename"
|
|
||||||
|
ssh -oStrictHostKeyChecking=no -oIdentitiesOnly=yes -i /tmp/sftp_key TeaSpeak-Travis-Web@web.teaspeak.dev "./unpack.sh $1 tmp-upload/$upload_name"
|
||||||
exit $?
|
exit $?
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
BASEDIR=$(dirname "$0")
|
BASEDIR=$(dirname "$0")
|
||||||
cd "$BASEDIR" || { echo "Failed to enter script base dir"; exit 1; }
|
cd "$BASEDIR" || { echo "Failed to enter script base dir"; exit 1; }
|
||||||
source ../scripts/resolve_commands.sh
|
|
||||||
|
|
||||||
function generate_declaration() {
|
function generate_declaration() {
|
||||||
echo "Generating declarations for project $1 ($2)"
|
echo "Generating declarations for project $1 ($2)"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {TranslationEntry} from "./Definitions";
|
import {TranslationEntry} from "../Definitions";
|
||||||
|
|
||||||
export const deltaTranslations = (result: TranslationEntry[], fileName: string, processSpeed: number, newTranslations: TranslationEntry[]) => {
|
export const deltaTranslations = (result: TranslationEntry[], fileName: string, processSpeed: number, newTranslations: TranslationEntry[]) => {
|
||||||
let deletedTranslations = 0;
|
let deletedTranslations = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue