From 8cc9fc412c9b89b5ce57ba659bb5c73990d2cc6c Mon Sep 17 00:00:00 2001 From: Christian Beer Date: Sun, 23 Sep 2018 16:37:27 +0200 Subject: [PATCH] Travis: harmonize deploy scripts On AppVeyor the archiving is done in prepare stage because they have an artefact cache for pull requests already available. So I moved the 7z stuff to prepare_deployment.sh so it does the same as the bath file. Filenames do not match because uploading to bintray is done differently but theyhave the same structure when available on bintray.. --- deploy/deploy_to_bintray.sh | 21 +++++++-------------- deploy/prepare_deployment.sh | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/deploy/deploy_to_bintray.sh b/deploy/deploy_to_bintray.sh index 875e618267..38f7ebd851 100755 --- a/deploy/deploy_to_bintray.sh +++ b/deploy/deploy_to_bintray.sh @@ -19,7 +19,8 @@ # ## Push binaries to Bintray (https://bintray.com/docs/api/) -## Creates a 7z archive from the content of $1 +## Uploads a specific 7z archive from directory given by $1 +## TODO: change arguments to include BOINC_TYPE and FILEPATH, eventually allow multiple files # be carefull with set -x in this script because of ${BINTRAY_API_KEY} which needs to stay secret set -e # Exit on errors @@ -51,7 +52,7 @@ if [ "${BINTRAY_API_KEY}" == "" ] ; then fi CI_RUN="${TRAVIS:-false}" -BOINC_TYPE="$(basename "${SOURCE_DIR}")" +BOINC_TYPE="$(basename "${SOURCE_DIR}")" # TODO: do not infer TYPE from directory, instead make it an argument API=https://api.bintray.com BINTRAY_USER="${BINTRAY_USER:-ChristianBeer}" BINTRAY_API_KEY="$BINTRAY_API_KEY" # env @@ -74,6 +75,7 @@ if [[ $CI_RUN == "true" ]]; then case $TRAVIS_EVENT_TYPE in pull_request) PKG_NAME="pull-requests" + GIT_REV=${TRAVIS_PULL_REQUEST_SHA:0:8} VERSION="PR${TRAVIS_PULL_REQUEST}_${BUILD_DATE}_${GIT_REV}" VERSION_DESC="CI build created from PR #${TRAVIS_PULL_REQUEST} on ${BUILD_DATE}" ;; @@ -108,19 +110,10 @@ data="{ set +x ${CURL} -H Content-Type:application/json -X POST -d "${data}" "${API}/packages/${BINTRAY_REPO_OWNER}/${BINTRAY_REPO}/${PKG_NAME}/versions" -echo "Uploading and publishing ${SOURCE_DIR}..." -PKG_DIR=$(dirname "${SOURCE_DIR}") -cd "${PKG_DIR}" -7z a "${BOINC_TYPE}.7z" "${BOINC_TYPE}/" &>/dev/null -if [ $? -gt 1 ]; then # an exit code of 1 is still a success says 7z - cd .. - echo "error while creating 7z archive; files not uploaded" - return 1 -fi -cd "${ROOTDIR}" -if [ -f "${PKG_DIR}/${BOINC_TYPE}.7z" ]; then +echo "Uploading and publishing ${SOURCE_DIR}/${BOINC_TYPE}.7z..." +if [ -f "${SOURCE_DIR}/${BOINC_TYPE}.7z" ]; then set +x - ${CURL} -H Content-Type:application/octet-stream -T "${PKG_DIR}/${BOINC_TYPE}.7z" "${API}/content/${BINTRAY_REPO_OWNER}/${BINTRAY_REPO}/${PKG_NAME}/${VERSION}/${BOINC_TYPE}_${VERSION}.7z?publish=1&override=1" + ${CURL} -H Content-Type:application/octet-stream -T "${SOURCE_DIR}/${BOINC_TYPE}.7z" "${API}/content/${BINTRAY_REPO_OWNER}/${BINTRAY_REPO}/${PKG_NAME}/${VERSION}/${BOINC_TYPE}_${VERSION}.7z?publish=1&override=1" fi if [ "$TRAVIS_BUILD_ID" ] ; then diff --git a/deploy/prepare_deployment.sh b/deploy/prepare_deployment.sh index 1f1327998e..4ec9aaed92 100755 --- a/deploy/prepare_deployment.sh +++ b/deploy/prepare_deployment.sh @@ -22,7 +22,6 @@ ## BOINC_TYPE should always be consistent with content in .travis.yml and appveyor.yml ## Change artefacts in each prepare_*() function below. ## Don't hardlink files because this can be run on a filesystem without hardlinks -## Don't put files into a zip as this is done by the actual deployment script ## On error always exit non-zero so the deploy script does not run # check working directory because the script needs to be called like: ./deploy/prepare_deployment.sh @@ -31,6 +30,7 @@ if [ ! -d "deploy" ]; then exit 1 fi +ROOTDIR=$(pwd) # main funtion is at the end cp_if_exists() { @@ -39,11 +39,26 @@ cp_if_exists() { fi } +prepare_7z_archive() { + if [[ $(ls -A "${TARGET_DIR}" | wc -l) -eq 0 ]]; then + echo "Directory '$TARGET_DIR' is empty"; + exit 1; + fi + cd "${TARGET_DIR}" + 7z a "${TYPE}.7z" '-x!*.7z' '*' &>/dev/null + if [ $? -gt 1 ]; then # an exit code of 1 is still a success says 7z + cd ${ROOTDIR} + echo "error while creating 7z archive; files not uploaded" + exit 1 + fi +} + prepare_client() { mkdir -p "${TARGET_DIR}" cp_if_exists client/boinc "${TARGET_DIR}" cp_if_exists client/boinccmd "${TARGET_DIR}" cp_if_exists client/switcher "${TARGET_DIR}" + prepare_7z_archive } prepare_apps() { @@ -59,11 +74,13 @@ prepare_apps() { cp_if_exists samples/vboxwrapper/vboxwrapper "${TARGET_DIR}" cp_if_exists samples/worker/worker "${TARGET_DIR}" cp_if_exists samples/wrapper/wrapper "${TARGET_DIR}" + prepare_7z_archive } prepare_manager() { mkdir -p "${TARGET_DIR}" cp_if_exists clientgui/boincmgr "${TARGET_DIR}" + prepare_7z_archive } prepare_apps_mingw() {