Merge topic 'rel-push'

9bf97363b0 Utilities/Release: Replace upload step with a "push" script
3a0ab3ba23 Utilities/Release: Teach upload script to compute version automatically

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3370
This commit is contained in:
Brad King 2019-05-28 15:42:38 +00:00 committed by Kitware Robot
commit da78d0f5ea
4 changed files with 72 additions and 47 deletions

View File

@ -188,12 +188,6 @@ Update ``Source/CMakeVersion.cmake`` to set the version to
set(CMake_VERSION_PATCH 0)
set(CMake_VERSION_RC 1)
Update ``Utilities/Release/upload_release.cmake``:
.. code-block:: cmake
set(VERSION $ver)
Update uses of ``DEVEL_CMAKE_VERSION`` in the source tree to mention the
actual version number:

View File

@ -770,14 +770,14 @@ if(BUILD_TESTING)
file(WRITE "${_TEST_DIR}/nightly-cmake.sh"
"cd ${_TEST_DIR}
${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGHTLY_RELEASES}'
")
add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh)
if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY)
set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
endif()
endmacro()
if(CMAKE_BUILD_NIGHTLY_RELEASES)
if(CMake_BUILD_NIGHTLY_RELEASES)
ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32
win32_release.cmake)
ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64

70
Utilities/Release/push.bash Executable file
View File

@ -0,0 +1,70 @@
#!/usr/bin/env bash
usage='usage: push.bash [<options>] [--] <dest>
Options:
--dir <dir> Specify subdirectory under destination.
Defaults to "v<version>".
--version <ver> CMake <major>.<minor> version number to push.
Defaults to version of source tree.
'
die() {
echo "$@" 1>&2; exit 1
}
cmake_source_dir="${BASH_SOURCE%/*}/../.."
cmake_version_component()
{
sed -n "
/^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
" "${cmake_source_dir}/Source/CMakeVersion.cmake"
}
version=''
dir=''
while test "$#" != 0; do
case "$1" in
--dir) shift; dir="$1" ;;
--version) shift; version="$1" ;;
--) shift ; break ;;
-*) die "$usage" ;;
*) break ;;
esac
shift
done
test "$#" = 1 || die "$usage"
readonly dest="$1"
if test -z "$version"; then
cmake_version_major="$(cmake_version_component MAJOR)"
cmake_version_minor="$(cmake_version_component MINOR)"
version="${cmake_version_major}.${cmake_version_minor}"
fi
readonly version
if test -z "$dir"; then
dir="v${version}"
fi
readonly dir
for f in cmake-${version}*; do
if ! test -f "${f}"; then
continue
fi
echo "pushing '${f}'"
# Make a copy with a new timestamp and atomically rename into place.
tf="${dest}/${dir}/.tmp.${f}"
df="${dest}/${dir}/${f}"
cp "${f}" "${tf}"
mv "${tf}" "${df}"
# Pause to give each file a distinct time stamp even with 1s resolution
# so that sorting by time also sorts alphabetically.
sleep 1.1
done

View File

@ -1,39 +0,0 @@
set(CTEST_RUN_CURRENT_SCRIPT 0)
if(NOT VERSION)
set(VERSION 3.14)
endif()
if(NOT DEFINED PROJECT_PREFIX)
set(PROJECT_PREFIX cmake-${VERSION})
endif()
if(NOT DEFINED DIR)
set(DIR "v${VERSION}")
endif()
file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*")
list(SORT FILES)
list(REVERSE FILES)
message("${FILES}")
set(UPLOAD_LOC
"kitware@www.cmake.org:/projects/FTP/pub/cmake/${DIR}")
set(count 0)
foreach(file ${FILES})
if(NOT IS_DIRECTORY ${file})
message("upload ${file} ${UPLOAD_LOC}")
execute_process(COMMAND
scp ${file} ${UPLOAD_LOC}
RESULT_VARIABLE result)
if("${result}" GREATER 0)
message(FATAL_ERROR "failed to upload file to ${UPLOAD_LOC}")
endif()
# Pause to give each upload a distinct (to the nearest second)
# time stamp
if(COMMAND ctest_sleep)
ctest_sleep(2)
endif()
math(EXPR count "${count} + 1")
endif()
endforeach()
if(${count} EQUAL 0)
message(FATAL_ERROR "Error no files uploaded.")
endif()