Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions resources/teamcity/keyboards/keyboards-build-deploy.sh
Original file line number Diff line number Diff line change
@@ -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"
Comment on lines +20 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume these need to be exported so ci.sh can get to them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should verify that all parameters are set here (as in keymanapp/lexical-models#319 (comment))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

_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
50 changes: 50 additions & 0 deletions resources/teamcity/keyboards/keyboards-notify-api.sh
Original file line number Diff line number Diff line change
@@ -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)
Comment on lines +25 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
local API_URL="$1"
local URL="https://${API_URL}/_control/webhook/keyboards-build-success.json?token=${WEBHOOK_TOKEN}"
local HTTPRESULT=$(curl --silent --write-out "\n\nHTTP status code: %{http_code}" "${URL}")
local STATUSCODE=$(echo "${HTTPRESULT}" | tail -n1 | cut -d" " -f 4)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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
29 changes: 29 additions & 0 deletions resources/teamcity/keyboards/keyboards-test-prs.sh
Original file line number Diff line number Diff line change
@@ -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