diff --git a/resources/teamcity/keyboards/keyboards-build-deploy.sh b/resources/teamcity/keyboards/keyboards-build-deploy.sh new file mode 100755 index 0000000000..32ccb7eaac --- /dev/null +++ b/resources/teamcity/keyboards/keyboards-build-deploy.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# Keyman is copyright (C) SIL Global. MIT License. + +# shellcheck disable=SC2164 +# shellcheck disable=SC1091 + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" +. "${THIS_SCRIPT%/*}/../../../resources/builder.inc.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +################################ Main script ################################ + +builder_describe \ + "Build and deploy keyboards" \ + "all run all actions" \ + "build build keyboards" \ + "publish deploy keyboards" \ + "--downloads-keyman-com=DOWNLOADS_KEYMAN_COM_URL URL of downloads server" \ + "--help-keyman-com=HELP_KEYMAN_COM Path to help.keyman.com repository" \ + "--s-keyman-com=S_KEYMAN_COM Path to s.keyman.com repository" \ + "--rsync-path=REMOTE_RSYNC_PATH Path to rsync on remote server" \ + "--rsync-dest=RSYNC_DEST Destination for rsync" + +builder_parse "$@" + +export DOWNLOADS_KEYMAN_COM_URL +export HELP_KEYMAN_COM +export S_KEYMAN_COM +export REMOTE_RSYNC_PATH +export RSYNC_DEST + +function do_build() { + builder_echo "Building all keyboards" + "${REPO_ROOT}/build.sh" + builder_echo "Finished building all keyboards" +} + +function _upload_to_downloads_keyman_com() { + builder_echo "Uploading keyboards to downloads.keyman.com" + "${REPO_ROOT}/ci.sh" -no-exe + builder_echo "Finished uploading keyboards to downloads.keyman.com" +} + +function _upload_to_s_keyman_com() { + builder_echo "Uploading new keyboards to s.keyman.com" + ( + cd "${REPO_ROOT}/resources" + "${REPO_ROOT}/resources/s-keyman-com.sh" + ) + builder_echo "Finished uploading new keyboards to s.keyman.com" +} + +function _upload_to_help_keyman_com() { + builder_echo "Uploading new keyboard help to help.keyman.com" + ( + cd "${REPO_ROOT}/resources" + "${REPO_ROOT}/resources/help-keyman-com.sh" + ) + builder_echo "Finished uploading new keyboard help to help.keyman.com" +} + +function do_publish() { + if [[ -z "${DOWNLOADS_KEYMAN_COM_URL:-}" ]]; then + builder_die "Option --downloads-keyman-com must be specified for publish action" + elif [[ -z "${HELP_KEYMAN_COM:-}" ]]; then + builder_die "Option --help-keyman-com must be specified for publish action" + elif [[ -z "${S_KEYMAN_COM:-}" ]]; then + builder_die "Option --s-keyman-com must be specified for publish action" + elif [[ -z "${REMOTE_RSYNC_PATH:-}" ]]; then + builder_die "Option --rsync-path must be specified for publish action" + elif [[ -z "${RSYNC_DEST:-}" ]]; then + builder_die "Option --rsync-dest must be specified for publish action" + fi + + _upload_to_downloads_keyman_com + _upload_to_s_keyman_com + _upload_to_help_keyman_com +} + +cd "${REPO_ROOT}" + +if builder_has_action all; then + do_build + do_publish +else + builder_run_action build do_build + builder_run_action publish do_publish +fi diff --git a/resources/teamcity/keyboards/keyboards-notify-api.sh b/resources/teamcity/keyboards/keyboards-notify-api.sh new file mode 100755 index 0000000000..266d570f9b --- /dev/null +++ b/resources/teamcity/keyboards/keyboards-notify-api.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Keyman is copyright (C) SIL Global. MIT License. + +# shellcheck disable=SC2164 +# shellcheck disable=SC1091 + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" +. "${THIS_SCRIPT%/*}/../../../resources/builder.inc.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +################################ Main script ################################ + +builder_describe \ + "Notify api.keyman.com of updated keyboards" \ + "all run all actions" \ + "--webhook-token=WEBHOOK_TOKEN Token for api.keyman.com webhook" + +builder_parse "$@" + +function _notify_api() { + local API_URL URL HTTPRESULT STATUSCODE + + API_URL=$1 + URL="https://${API_URL}/_control/webhook/keyboards-build-success.json?token=${WEBHOOK_TOKEN}" + HTTPRESULT=$(curl --silent --write-out "\n\nHTTP status code: %{http_code}" "${URL}") + STATUSCODE=$(echo "${HTTPRESULT}" | tail -n1 | cut -d" " -f 4) + builder_echo "${HTTPRESULT}" + if [[ $STATUSCODE -ne 200 ]]; then + builder_echo "-----------------------------------" + builder_echo error "ERROR: call failed with $STATUSCODE" + exit 1 + fi +} + +function do_notify_api_keyman_com() { + builder_echo "Notifying api.keyman.com of updated keyboards" + _notify_api "api.keyman.com" + builder_echo "Finished notifying api.keyman.com of updated keyboards" +} + +function do_notify_api_keyman_staging_com() { + builder_echo "Notifying api.keyman-staging.com of updated keyboards" + _notify_api "api.keyman-staging.com" + builder_echo "Finished notifying api.keyman-staging.com of updated keyboards" +} + +do_notify_api_keyman_com +do_notify_api_keyman_staging_com diff --git a/resources/teamcity/keyboards/keyboards-test-prs.sh b/resources/teamcity/keyboards/keyboards-test-prs.sh new file mode 100755 index 0000000000..c26952decc --- /dev/null +++ b/resources/teamcity/keyboards/keyboards-test-prs.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Keyman is copyright (C) SIL Global. MIT License. + +# shellcheck disable=SC2164 +# shellcheck disable=SC1091 + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" +. "${THIS_SCRIPT%/*}/../../../resources/builder.inc.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +################################ Main script ################################ + +builder_describe \ + "Test build of pull request" \ + "all run all actions" + +builder_parse "$@" + +function do_build() { + builder_echo "Building all keyboards" + "${REPO_ROOT}/build.sh" + builder_echo "Finished building all keyboards" +} + +cd "${REPO_ROOT}" + +builder_run_action all do_build