From da51e1510e0455264d1c43de9f01cab6a230a4dc Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:34:19 +0100 Subject: [PATCH] Let release-developer publish the version the sources already name (#539) A pull request that changes the environment advances distribution.json ahead of the pin, and the workflow then refused that very version. The requested version must now be greater than the published pin and not lower than the sources. --- .github/workflows/ReleaseDeveloper.yml | 12 ++++----- js/developer/tools/PUBLISHING.md | 4 ++- js/developer/tools/check-release-version.sh | 19 ++++++++++++++ test/cmake/CheckReleaseWorkflow.cmake | 5 ++++ test/cmake/CheckReleaseWorkflowTests.cmake | 28 +++++++++++++++++++++ 5 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 js/developer/tools/check-release-version.sh diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index 18722906..1d1cc8b2 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: inputs: version: - description: Version of the environment to release (MAJOR.MINOR.PATCH, greater than the one of distribution.json) + description: Version of the environment to release (MAJOR.MINOR.PATCH, greater than the published one and not lower than the one of distribution.json) type: string required: true publish: @@ -56,12 +56,10 @@ jobs: run: echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - name: Check the requested version run: | - [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Version must be MAJOR.MINOR.PATCH"; exit 1; } - current=$(jq -r .version js/developer/tools/distribution.json) - if [ "$(printf '%s\n%s\n' "$current" "$VERSION" | sort -V | tail -n 1)" != "$VERSION" ] || [ "$current" = "$VERSION" ]; then - echo "::error::Version $VERSION must be greater than the current $current" - exit 1 - fi + # The sources may already name the version under development; the published version is never released again. + sources=$(jq -r .version js/developer/tools/distribution.json) + pinned=$(sed -n 's/.*version{"\([^"]*\)"}.*/\1/p' include/webfront/system/DeveloperReleaseData.hpp) + bash js/developer/tools/check-release-version.sh "$VERSION" "$sources" "$pinned" - uses: ./.github/actions/remove-node - uses: ./.github/actions/wf-driver - name: Set the version and close a migration diff --git a/js/developer/tools/PUBLISHING.md b/js/developer/tools/PUBLISHING.md index d160246b..05c63417 100644 --- a/js/developer/tools/PUBLISHING.md +++ b/js/developer/tools/PUBLISHING.md @@ -13,7 +13,9 @@ and `jq` for the host operations. ## Releasing with the workflow The **release-developer** workflow (`.github/workflows/ReleaseDeveloper.yml`, ADR-021) is the way to publish a version. Dispatch -it on `develop` with the version (greater than the one of `distribution.json`): +it on `develop` with the version: greater than the published one (the pin of `DeveloperReleaseData.hpp`) and not lower than +the one of `distribution.json`, so the version that a merged pull request already gave the sources can be released as it is +(`check-release-version.sh`): ```sh gh workflow run ReleaseDeveloper.yml --ref develop -f version=0.6.7 -f publish=false # rehearsal diff --git a/js/developer/tools/check-release-version.sh b/js/developer/tools/check-release-version.sh new file mode 100644 index 00000000..0d893bec --- /dev/null +++ b/js/developer/tools/check-release-version.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Accepts the version of a release of the developer environment: check-release-version.sh . +# is the version of distribution.json and the published one of DeveloperReleaseData.hpp. A pull request +# that changes the environment advances the sources ahead of the pin, so the requested version may be the one the sources +# already name; it is never below the sources, and always above the published version, which is immutable. +set -euo pipefail +requested=${1:?requested version} sources=${2:?version of the sources} pinned=${3:?pinned version} +for version in "$requested" "$sources" "$pinned"; do + [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Version '$version' must be MAJOR.MINOR.PATCH"; exit 1; } +done +newest() { printf '%s\n' "$@" | sort -V | tail -n 1; } +if [ "$(newest "$sources" "$requested")" != "$requested" ]; then + echo "::error::Version $requested must not be lower than the $sources of the sources" + exit 1 +fi +if [ "$requested" = "$pinned" ] || [ "$(newest "$pinned" "$requested")" != "$requested" ]; then + echo "::error::Version $requested must be greater than the published $pinned" + exit 1 +fi diff --git a/test/cmake/CheckReleaseWorkflow.cmake b/test/cmake/CheckReleaseWorkflow.cmake index bbed1da9..4fa751b5 100644 --- a/test/cmake/CheckReleaseWorkflow.cmake +++ b/test/cmake/CheckReleaseWorkflow.cmake @@ -121,6 +121,11 @@ if(NOT content MATCHES "cmake -S [.] -B build-driver\n") message(FATAL_ERROR "The rehearsal does not configure build-driver again after setting the version") endif() +# The requested version is compared with the sources and with the published pin: a published version is immutable. +if(NOT content MATCHES "check-release-version[.]sh \"[$]VERSION\" \"[$]sources\" \"[$]pinned\"") + message(FATAL_ERROR "The workflow does not check the requested version against the sources and the published pin") +endif() + # The tag step can be rerun after a lost response: it accepts a tag that already points at the release commit. if(NOT content MATCHES "echo \"[$]tag already points at the release commit\"") message(FATAL_ERROR "The tag step is not rerunnable: it must accept an existing tag at the release commit") diff --git a/test/cmake/CheckReleaseWorkflowTests.cmake b/test/cmake/CheckReleaseWorkflowTests.cmake index 1c69dc0f..097d0b7a 100644 --- a/test/cmake/CheckReleaseWorkflowTests.cmake +++ b/test/cmake/CheckReleaseWorkflowTests.cmake @@ -65,3 +65,31 @@ check("a release that leaves the guide on the former pin" refuse "does not name "Name the pin in the developer environment guide" "Other step") check("a release that skips the offline pin check" refuse "does not run CheckDeveloperPin" "test/cmake/CheckDeveloperPin.cmake" "test/cmake/Other.cmake") +check("a release that does not compare its version with the published pin" refuse "does not check the requested version" + "check-release-version.sh \"$VERSION\" \"$sources\" \"$pinned\"" "check-release-version.sh \"$VERSION\" \"$sources\" \"$sources\"") + +# The version rule itself: . It needs bash, as the workflow that runs it does. +find_program(BASH_PROGRAM bash) +if(NOT BASH_PROGRAM) + message(STATUS "bash not found: the version rule of the release is not exercised") + return() +endif() +function(check_version description expected message requested sources pinned) + execute_process(COMMAND "${BASH_PROGRAM}" "${ROOT}/js/developer/tools/check-release-version.sh" "${requested}" "${sources}" "${pinned}" + RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) + if(expected STREQUAL "accept" AND NOT result EQUAL 0) + message(FATAL_ERROR "${description}: refused: ${output}${error}") + elseif(expected STREQUAL "refuse" AND result EQUAL 0) + message(FATAL_ERROR "${description}: accepted") + endif() + if(NOT "${output}${error}" MATCHES "${message}") + message(FATAL_ERROR "${description}: missing diagnostic '${message}': ${output}${error}") + endif() +endfunction() +check_version("the version the sources already name, ahead of the pin" accept "" 0.9.1 0.9.1 0.9.0) +check_version("a version above the sources and the pin" accept "" 0.10.0 0.9.1 0.9.0) +check_version("a version above sources that still name the pin" accept "" 0.9.1 0.9.0 0.9.0) +check_version("the published version again" refuse "greater than the published 0.9.0" 0.9.0 0.9.0 0.9.0) +check_version("a version below the sources" refuse "not be lower than the 0.9.1" 0.9.0 0.9.1 0.8.0) +check_version("a version below the pin" refuse "greater than the published 0.10.0" 0.9.9 0.9.1 0.10.0) +check_version("a version that is not MAJOR.MINOR.PATCH" refuse "MAJOR.MINOR.PATCH" 0.9 0.9.1 0.9.0)