Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/ReleaseDeveloper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion js/developer/tools/PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions js/developer/tools/check-release-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Accepts the version of a release of the developer environment: check-release-version.sh <requested> <sources> <pinned>.
# <sources> is the version of distribution.json and <pinned> 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
5 changes: 5 additions & 0 deletions test/cmake/CheckReleaseWorkflow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
28 changes: 28 additions & 0 deletions test/cmake/CheckReleaseWorkflowTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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: <requested> <sources> <pinned>. 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)
Loading