maint(web): move rsync code to shared functions

Build-bot: skip
Test-bot: skip
This commit is contained in:
Eberhard Beilharz 2025-07-02 11:51:25 +02:00
parent cd796fe770
commit 52943600dc
No known key found for this signature in database
GPG key ID: E9140597606020D3
2 changed files with 44 additions and 19 deletions

View file

@ -80,3 +80,42 @@ upload_help() {
builder_echo end "upload help" success "Finished uploading new ${PRODUCT} help to help.keyman.com"
}
_tc_rsync() {
local rsync_args CYGPATH_RSYNC_HOME SOURCE DESTINATION
SOURCE=$1
DESTINATION=$2
if ! is_windows; then
echo "This function is currently only supported on Windows."
return 1
fi
rsync_args=(
'-vrzltp' # verbose, recurse, zip, copy symlinks, preserve times, permissions
'--chmod=Dug=rwx,Do=rx,Fug=rw,Fo=r' # map Windows security to host security
'--stats' # show statistics for log
"--rsync-path=${RSYNC_PATH}" # path on remote server
"--rsh=${RSYNC_HOME}\ssh -i ${USERPROFILE}\.ssh\id_rsa -o UserKnownHostsFile=${USERPROFILE}\.ssh\known_hosts" # use ssh
"${SOURCE}"
"${DESTINATION}"
)
CYGPATH_RSYNC_HOME=$(cygpath -w "${RSYNC_HOME}")
MSYS_NO_PATHCONV=1 "${CYGPATH_RSYNC_HOME}\\rsync.exe" "${rsync_args[@]}"
}
# Download file or directory $1 from the remote server to $2.
tc_rsync_download() {
# shellcheck disable=SC2154
_tc_rsync \
"${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_ROOT}/$1" \
"$2"
}
# Upload file or directory $1 to the remote server at $2.
tc_rsync_upload() {
_tc_rsync \
"$1" \
"${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_ROOT}/$2"
}

View file

@ -56,31 +56,17 @@ function _zip_and_upload_artifacts() {
cd "${KEYMAN_ROOT}/web"
local UPLOAD_DIR="build/upload/$KEYMAN_VERSION"
local UPLOAD_DIR="build/upload/${KEYMAN_VERSION}"
./ci.sh prepare:downloads.keyman.com
write_download_info "$UPLOAD_DIR" "keymanweb-$KEYMAN_VERSION.zip" KeymanWeb zip web
write_download_info "${UPLOAD_DIR}" "keymanweb-${KEYMAN_VERSION}.zip" KeymanWeb zip web
rsync_args=(
'-vrzltp' # verbose, recurse, zip, copy symlinks, preserve times, permissions
'--chmod=Dug=rwx,Do=rx,Fug=rw,Fo=r' # map Windows security to host security
'--stats' # show statistics for log
"--rsync-path=${RSYNC_PATH}" # path on remote server
"--rsh=${RSYNC_HOME}\ssh -i ${USERPROFILE}\.ssh\id_rsa -o UserKnownHostsFile=${USERPROFILE}\.ssh\known_hosts" # use ssh
"${KEYMAN_VERSION}" # upload the whole build folder
"${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_ROOT}/web/${KEYMAN_TIER}/" # target server + path
(
cd build/upload
tc_rsync_upload "${KEYMAN_VERSION}" "web/${KEYMAN_TIER}"
)
cd build/upload
local CYGPATH_RSYNC_HOME=$(cygpath -w "$RSYNC_HOME")
# DEBUG: echo "${rsync_args[@]}"
# DEBUG: MSYS_NO_PATHCONV=1 "C:\\Users\\marc\\source\\repos\\doecho\\Debug\\doecho.exe" "${CYGPATH_RSYNC_HOME}\\rsync.exe" "${rsync_args[@]}"
MSYS_NO_PATHCONV=1 "${CYGPATH_RSYNC_HOME}\\rsync.exe" "${rsync_args[@]}"
cd "${KEYMAN_ROOT}/web"
builder_echo end "zip and upload artifacts" success "Finished zipping and uploading artifacts"
}