diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b3fda66e5..ad06ff9f0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,6 +72,12 @@ u:source-package: needs: - p:source-package +b:version-update: + extends: + - .cmake_version_update_linux + - .linux_x86_64_tags + - .run_version_update + # Documentation builds b:cmake.org-help: diff --git a/.gitlab/ci/cmake_version_update.sh b/.gitlab/ci/cmake_version_update.sh new file mode 100755 index 0000000000..6b90f84fb5 --- /dev/null +++ b/.gitlab/ci/cmake_version_update.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -e + +if test "$CI_COMMIT_REF_NAME" != "master"; then + echo "The version update may run only on the 'master' branch." + exit 1 +fi + +# A project-specific access token must be provided by +# the pipeline schedule under which this job runs. +if test -z "$CMAKE_CI_GIT_ACCESS_TOKEN"; then + echo "No CMAKE_CI_GIT_ACCESS_TOKEN is available." + exit 1 +fi + +git config user.name "${CMAKE_CI_AUTHOR_NAME-Kitware Robot}" +git config user.email "${CMAKE_CI_AUTHOR_EMAIL-kwrobot@kitware.com}" +git remote add upstream "https://oauth2:$CMAKE_CI_GIT_ACCESS_TOKEN@gitlab.kitware.com/$CI_PROJECT_PATH.git" + +# Repeat a few times in case we lose a race. +n=6 +for try in $(seq $n); do + git fetch upstream "$CI_COMMIT_REF_NAME" + git reset -q --hard FETCH_HEAD + Source/CMakeVersion.bash + git update-index -q --ignore-missing --refresh + modified=$(git diff-index --name-only HEAD -- "Source/CMakeVersion.cmake") + if test -n "$modified"; then + echo "version changed" + git add -u + git commit -m "CMake Nightly Date Stamp" + if git push --push-option=ci.skip upstream "HEAD:$CI_COMMIT_REF_NAME"; then + exit 0 + else + echo "Try #$try failed to fast-forward." + fi + else + echo "version unchanged" + exit 0 + fi + sleep 30 +done + +# Give up after failing too many times. +exit 1 diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 6b8c2d0408..cbdaa8e27b 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -549,6 +549,13 @@ interruptible: true +.cmake_version_update_linux: + stage: build + extends: .fedora41 + script: + - .gitlab/ci/cmake_version_update.sh + interruptible: false # The job internally fetches and retries. + .cmake_codespell_linux: stage: build extends: .fedora41 diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml index 0402d33558..c7102f95c7 100644 --- a/.gitlab/rules.yml +++ b/.gitlab/rules.yml @@ -2,7 +2,7 @@ .run_manually: rules: - - if: '$CMAKE_CI_PACKAGE != null' + - if: '$CMAKE_CI_PACKAGE != null || $CMAKE_CI_VERSION_UPDATE != null' when: never - if: '($CMAKE_CI_NIGHTLY == "true" && $CMAKE_CI_JOB_NIGHTLY == "false")' when: never @@ -25,7 +25,7 @@ .run_automatically: rules: - - if: '$CMAKE_CI_PACKAGE != null' + - if: '$CMAKE_CI_PACKAGE != null || $CMAKE_CI_VERSION_UPDATE != null' when: never - if: '($CMAKE_CI_NIGHTLY == "true" && $CMAKE_CI_JOB_NIGHTLY == "false")' when: never @@ -48,7 +48,7 @@ .run_dependent: rules: - - if: '$CMAKE_CI_PACKAGE != null' + - if: '$CMAKE_CI_PACKAGE != null || $CMAKE_CI_VERSION_UPDATE != null' when: never - if: '($CMAKE_CI_NIGHTLY == "true" && $CMAKE_CI_JOB_NIGHTLY == "false")' when: never @@ -86,6 +86,8 @@ .run_cmake_org_help: rules: + - if: '$CMAKE_CI_VERSION_UPDATE != null' + when: never - if: '$CMAKE_CI_PACKAGE =~ /v[0-9]+\.[0-9]+/' variables: RSYNC_DESTINATION: "kitware@cmake.org:$CMAKE_CI_PACKAGE/" @@ -105,3 +107,9 @@ CMAKE_CI_VERSION_NO_GIT: "OFF" when: on_success - when: never + +.run_version_update: + rules: + - if: '$CMAKE_CI_VERSION_UPDATE != null' + when: on_success + - when: never