From b53554f9dbe45a32fae9c7ada518beb3b8a3d2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 10 Oct 2025 22:14:47 +0200 Subject: [PATCH 1/9] docs/conf.py: Fix wrong assumption that missing prerelease.txt represents a release --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 3f7dc3e350ac..74e45fa2a6cc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -126,7 +126,7 @@ def get_github_username_repo(url): with open('../CMakeLists.txt', 'r', encoding='utf8') as f: version = re.search('PROJECT_VERSION "([^"]+)"', f.read()).group(1) # The full version, including alpha/beta/rc tags. -if not os.path.isfile('../prerelease.txt') or os.path.getsize('../prerelease.txt') == 0: +if os.path.isfile('../prerelease.txt') and os.path.getsize('../prerelease.txt') == 0: release = version else: # This is a prerelease version From 6c068b3049f7351d22ca02ae401d68ab22c2d8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Wed, 15 Oct 2025 19:29:10 +0200 Subject: [PATCH 2/9] docs/conf.py: Include the content of prerelease.txt in the version string --- docs/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 74e45fa2a6cc..e71535b9a786 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -128,8 +128,10 @@ def get_github_username_repo(url): # The full version, including alpha/beta/rc tags. if os.path.isfile('../prerelease.txt') and os.path.getsize('../prerelease.txt') == 0: release = version +elif os.path.isfile('../prerelease.txt'): + with open('../prerelease.txt', 'r', encoding='utf8') as prerelease_file: + release = version + '-' + prerelease_file.read() else: - # This is a prerelease version release = version + '-develop' # The language for content autogenerated by Sphinx. Refer to documentation From 15964caad18dd06a41ddf039c330f0e60213870d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 10 Oct 2025 21:13:40 +0200 Subject: [PATCH 3/9] Remove special-casing of the `release` branch - I think we used to have such a branch in the past, but we no longer do and it being handled specially would be completely unexpected by everyone at this point. --- .circleci/config.yml | 2 +- scripts/ci/build.sh | 4 ++-- scripts/ci/build_emscripten.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 58bcb2b9fb81..bb8acb97b1a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -187,7 +187,7 @@ commands: - run: name: Store commit hash and prerelease command: | - if [[ $CIRCLE_BRANCH == release || -n $CIRCLE_TAG ]]; then + if [[ -n $CIRCLE_TAG ]]; then echo -n > prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" > prerelease.txt; diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index 1acec5a20113..451638371f61 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -9,7 +9,7 @@ prerelease_source="${1:-ci}" cd "${ROOTDIR}" -if [[ $CIRCLE_BRANCH == release || -n $CIRCLE_TAG || -n $FORCE_RELEASE ]]; then +if [[ -n $CIRCLE_TAG || -n $FORCE_RELEASE ]]; then echo -n > prerelease.txt else # Use last commit date rather than build date to avoid ending up with builds for @@ -25,7 +25,7 @@ fi mkdir -p build cd build -[[ -n $COVERAGE && $CIRCLE_BRANCH != release && -z $CIRCLE_TAG ]] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON" +[[ -n $COVERAGE && -z $CIRCLE_TAG ]] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON" # shellcheck disable=SC2086 cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" $CMAKE_OPTIONS diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index 836c4d41c553..71fc888ea32e 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -45,7 +45,7 @@ function build() { cd "${ROOT_DIR}" - if [[ $CIRCLE_BRANCH == release || -n $CIRCLE_TAG || -n $FORCE_RELEASE || $(git tag --points-at HEAD 2> /dev/null) == v* ]]; then + if [[ -n $CIRCLE_TAG || -n $FORCE_RELEASE || $(git tag --points-at HEAD 2> /dev/null) == v* ]]; then echo -n > prerelease.txt else # Use last commit date rather than build date to avoid ending up with builds for From 5c21b7fad3a4348743c36a6433b01b776776a4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 10 Oct 2025 19:19:49 +0200 Subject: [PATCH 4/9] Do not store CIRCLE_SHA1 in commit_hash.txt - It is not necessary, because when missing, our CMake config will fetch it from git. --- .circleci/config.yml | 9 ++++----- scripts/ci/build.sh | 4 ---- scripts/ci/build_emscripten.sh | 3 --- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bb8acb97b1a7..fc267010a394 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -182,17 +182,16 @@ commands: # -------------------------------------------------------------------------- # Build Commands - setup_prerelease_commit_hash: + setup_prerelease: steps: - run: - name: Store commit hash and prerelease + name: Store prerelease suffix command: | if [[ -n $CIRCLE_TAG ]]; then echo -n > prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" > prerelease.txt; fi - echo -n "$CIRCLE_SHA1" > commit_hash.txt install_and_check_minimum_requirements: parameters: @@ -1115,7 +1114,7 @@ jobs: <<: *base_ubuntu_clang_large steps: - checkout - - setup_prerelease_commit_hash + - setup_prerelease - run_build_ossfuzz - persist_ossfuzz_executables_to_workspace - matrix_notify_failure_unless_pr @@ -1225,7 +1224,7 @@ jobs: <<: *base_ubuntu2404_small steps: - checkout - - setup_prerelease_commit_hash + - setup_prerelease - run: name: Install build system dependencies command: | diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index 451638371f61..fae017d32605 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -18,10 +18,6 @@ else TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" > prerelease.txt fi -if [[ -n $CIRCLE_SHA1 ]]; then - echo -n "$CIRCLE_SHA1" > commit_hash.txt -fi - mkdir -p build cd build diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index 71fc888ea32e..9da9f9bc5994 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -53,9 +53,6 @@ function build() { # if the CI is triggered just before midnight. TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" > prerelease.txt fi - if [[ -n $CIRCLE_SHA1 ]]; then - echo -n "$CIRCLE_SHA1" > commit_hash.txt - fi # Disable warnings for unqualified `move()` calls, introduced and enabled by # default in clang-16 which is what the emscripten docker image uses. From 2b950bb878b4accb08567d2296179a16c8411257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 10 Oct 2025 19:08:08 +0200 Subject: [PATCH 5/9] create_source_tarball.sh: Fail when commit_hash.txt is present instead of ignoring it --- scripts/create_source_tarball.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/create_source_tarball.sh b/scripts/create_source_tarball.sh index 1a3099245352..af13899cdbb2 100755 --- a/scripts/create_source_tarball.sh +++ b/scripts/create_source_tarball.sh @@ -2,6 +2,9 @@ set -euo pipefail REPO_ROOT="$(dirname "$0")"/.. +# shellcheck source=scripts/common.sh +source "${REPO_ROOT}/scripts/common.sh" + cd "$REPO_ROOT" version=$(scripts/get_version.sh) commit_hash=$(git rev-parse --short=8 HEAD) @@ -14,6 +17,11 @@ else version_string="${version}-nightly-${commit_date}-${commit_hash}" fi +# The only purpose of commit_hash.txt is to make it possible to build the compiler without git. +# It is not meant as an override of the real hash. +[[ ! -e commit_hash.txt ]] || \ + fail "commit_hash.txt is present in the repository root, but will not be used to override the commit hash for the source package." + TEMPDIR=$(mktemp -d -t "solc-src-tarball-XXXXXX") SOLDIR="${TEMPDIR}/solidity_${version_string}/" mkdir "$SOLDIR" From a3874f09541b1a47ab354378a63d490e6ec7b1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 10 Oct 2025 18:56:42 +0200 Subject: [PATCH 6/9] create_source_tarball.sh: Use prerelease name from prerelease.txt when available instead of hard-coding "nightly" --- scripts/create_source_tarball.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/create_source_tarball.sh b/scripts/create_source_tarball.sh index af13899cdbb2..28e41edf0ad7 100755 --- a/scripts/create_source_tarball.sh +++ b/scripts/create_source_tarball.sh @@ -13,6 +13,8 @@ commit_date=$(git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/ # File exists and has zero size -> not a prerelease if [[ -e prerelease.txt && ! -s prerelease.txt ]]; then version_string="$version" +elif [[ -e prerelease.txt ]]; then + version_string="${version}-$(cat prerelease.txt)-${commit_hash}" else version_string="${version}-nightly-${commit_date}-${commit_hash}" fi From af138bf2ce5934adae7316418ea3c29ed84bea1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Wed, 15 Oct 2025 18:51:12 +0200 Subject: [PATCH 7/9] create_source_tarball.sh: Use UTC timezone when determining the prerelease date --- scripts/create_source_tarball.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_source_tarball.sh b/scripts/create_source_tarball.sh index 28e41edf0ad7..c175b5045f4c 100755 --- a/scripts/create_source_tarball.sh +++ b/scripts/create_source_tarball.sh @@ -8,7 +8,7 @@ source "${REPO_ROOT}/scripts/common.sh" cd "$REPO_ROOT" version=$(scripts/get_version.sh) commit_hash=$(git rev-parse --short=8 HEAD) -commit_date=$(git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./') +commit_date=$(TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="%cd") # File exists and has zero size -> not a prerelease if [[ -e prerelease.txt && ! -s prerelease.txt ]]; then From 8fe0df0761ef47c004488da0a00a30ce1fc86336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 10 Oct 2025 19:43:39 +0200 Subject: [PATCH 8/9] Unify the prerelease suffix logic across all scripts and CI --- .circleci/config.yml | 6 +----- scripts/build.sh | 6 ++++-- scripts/ci/build.sh | 9 +-------- scripts/ci/build_emscripten.sh | 9 +-------- scripts/ci/build_win.sh | 15 +-------------- scripts/prerelease_suffix.sh | 27 +++++++++++++++++++++++++++ 6 files changed, 35 insertions(+), 37 deletions(-) create mode 100755 scripts/prerelease_suffix.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index fc267010a394..e5f4d3cb3b3d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -187,11 +187,7 @@ commands: - run: name: Store prerelease suffix command: | - if [[ -n $CIRCLE_TAG ]]; then - echo -n > prerelease.txt; - else - date -u +"nightly.%Y.%-m.%-d" > prerelease.txt; - fi + "scripts/prerelease_suffix.sh" nightly "$CIRCLE_TAG" > prerelease.txt install_and_check_minimum_requirements: parameters: diff --git a/scripts/build.sh b/scripts/build.sh index 5d7765e6b27d..33d7bb7c5104 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -10,8 +10,10 @@ else BUILD_TYPE="$1" fi -if [[ $(git tag --points-at HEAD 2> /dev/null) == v* ]]; then - touch "${ROOTDIR}/prerelease.txt" +# Intentionally not using prerelease_suffix.sh here. We do not want lingering prerelease.txt in +# dev builds, accidentally overriding version when someone runs the build manually. +if [[ $(git tag --points-at HEAD 2> /dev/null) =~ ^v[0-9.]+$ ]]; then + echo -n > prerelease.txt fi mkdir -p "$BUILDDIR" diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index fae017d32605..b7f7e92f5708 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -9,14 +9,7 @@ prerelease_source="${1:-ci}" cd "${ROOTDIR}" -if [[ -n $CIRCLE_TAG || -n $FORCE_RELEASE ]]; then - echo -n > prerelease.txt -else - # Use last commit date rather than build date to avoid ending up with builds for - # different platforms having different version strings (and therefore producing different bytecode) - # if the CI is triggered just before midnight. - TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" > prerelease.txt -fi +"${ROOTDIR}/scripts/prerelease_suffix.sh" "$prerelease_source" "$CIRCLE_TAG" > prerelease.txt mkdir -p build cd build diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index 9da9f9bc5994..50c851af8448 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -45,14 +45,7 @@ function build() { cd "${ROOT_DIR}" - if [[ -n $CIRCLE_TAG || -n $FORCE_RELEASE || $(git tag --points-at HEAD 2> /dev/null) == v* ]]; then - echo -n > prerelease.txt - else - # Use last commit date rather than build date to avoid ending up with builds for - # different platforms having different version strings (and therefore producing different bytecode) - # if the CI is triggered just before midnight. - TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" > prerelease.txt - fi + "${SCRIPT_DIR}/prerelease_suffix.sh" "$prerelease_source" "$(git tag --points-at HEAD 2> /dev/null)" > prerelease.txt # Disable warnings for unqualified `move()` calls, introduced and enabled by # default in clang-16 which is what the emscripten docker image uses. diff --git a/scripts/ci/build_win.sh b/scripts/ci/build_win.sh index 647cb02d95b6..64d63c58f4ef 100755 --- a/scripts/ci/build_win.sh +++ b/scripts/ci/build_win.sh @@ -8,20 +8,7 @@ FORCE_RELEASE="${FORCE_RELEASE:-}" CIRCLE_TAG="${CIRCLE_TAG:-}" cd "$ROOTDIR" -if [[ $FORCE_RELEASE != "" || $CIRCLE_TAG != "" ]]; then - echo -n > prerelease.txt -else - # Use last commit date rather than build date to avoid ending up with builds for - # different platforms having different version strings (and therefore producing different bytecode) - # if the CI is triggered just before midnight. - # NOTE: The -local suffix makes git not use the timezone from the commit but instead convert to - # local one, which we explicitly set to UTC. - # NOTE: git --date is supposed to support the %-m/%-d format too, but it does not seem to - # work on Windows. Without it we get leading zeros for month and day. - last_commit_date=$(TZ=UTC git show --quiet --date="format-local:%Y-%m-%d" --format="%cd") - last_commit_date_stripped=$(date --date="$last_commit_date" "+%Y.%-m.%-d") - echo -n "${prerelease_source}.${last_commit_date_stripped}" > prerelease.txt -fi +"${ROOTDIR}/scripts/prerelease_suffix.sh" "$prerelease_source" "$CIRCLE_TAG" > prerelease.txt mkdir -p build/ cd build/ diff --git a/scripts/prerelease_suffix.sh b/scripts/prerelease_suffix.sh new file mode 100755 index 000000000000..dc70f706e6c4 --- /dev/null +++ b/scripts/prerelease_suffix.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +(( $# <= 2 )) || { >&2 echo "Usage: $0 [PRERELEASE_SOURCE] [GIT_TAG]"; exit 1; } +prerelease_source="${1:-nightly}" +git_tag="${2:-}" +FORCE_RELEASE="${FORCE_RELEASE:-}" + +GNU_DATE="date" +if [[ "$OSTYPE" == "darwin"* ]]; then + GNU_DATE=gdate +fi + +if [[ $FORCE_RELEASE != "" || $git_tag == v* ]]; then + echo -n +else + # Use last commit date rather than build date to avoid ending up with builds for + # different platforms having different version strings (and therefore producing different bytecode) + # if the CI is triggered just before midnight. + # NOTE: The -local suffix makes git not use the timezone from the commit but instead convert to + # local one, which we explicitly set to UTC. + # NOTE: git --date is supposed to support the %-m/%-d format too, but it does not seem to + # work on Windows. Without it we get leading zeros for month and day. + last_commit_date=$(TZ=UTC git show --quiet --date="format-local:%Y-%m-%d" --format="%cd") + last_commit_date_stripped=$("$GNU_DATE" --date "$last_commit_date" "+%Y.%-m.%-d") + echo -n "${prerelease_source}.${last_commit_date_stripped}" +fi From 8439e2abdb471bb7d19e98c06226cd25af002cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 10 Oct 2025 22:50:47 +0200 Subject: [PATCH 9/9] Handle tagged prereleases separately from releases and other prereleases --- .circleci/config.yml | 1 + scripts/create_source_tarball.sh | 20 ++++++++++++++------ scripts/prerelease_suffix.sh | 4 +++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e5f4d3cb3b3d..5d3db526ad41 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1001,6 +1001,7 @@ jobs: <<: *base_ubuntu2404_xlarge steps: - build + - run: cat prerelease.txt # x64 ASAN build, for testing for memory related bugs b_ubu_asan: &b_ubu_asan diff --git a/scripts/create_source_tarball.sh b/scripts/create_source_tarball.sh index c175b5045f4c..0e135ad8242e 100755 --- a/scripts/create_source_tarball.sh +++ b/scripts/create_source_tarball.sh @@ -8,14 +8,22 @@ source "${REPO_ROOT}/scripts/common.sh" cd "$REPO_ROOT" version=$(scripts/get_version.sh) commit_hash=$(git rev-parse --short=8 HEAD) -commit_date=$(TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="%cd") -# File exists and has zero size -> not a prerelease -if [[ -e prerelease.txt && ! -s prerelease.txt ]]; then - version_string="$version" -elif [[ -e prerelease.txt ]]; then - version_string="${version}-$(cat prerelease.txt)-${commit_hash}" +if [[ -e prerelease.txt ]]; then + prerelease_suffix=$(cat prerelease.txt) + if [[ $prerelease_suffix == "" ]]; then + # File exists and has zero size -> not a prerelease + version_string="$version" + elif [[ $prerelease_suffix == pre.* ]]; then + # Tagged prerelease -> unambiguous, so commit hash not needed + version_string="${version}-${prerelease_suffix}" + else + # Nightly/develop/other prerelease -> include commit hash + version_string="${version}-${prerelease_suffix}-${commit_hash}" + fi else + # Nightly/develop/other prerelease -> include commit hash + default prerelease suffix + commit_date=$(TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="%cd") version_string="${version}-nightly-${commit_date}-${commit_hash}" fi diff --git a/scripts/prerelease_suffix.sh b/scripts/prerelease_suffix.sh index dc70f706e6c4..2913b12fb441 100755 --- a/scripts/prerelease_suffix.sh +++ b/scripts/prerelease_suffix.sh @@ -11,8 +11,10 @@ if [[ "$OSTYPE" == "darwin"* ]]; then GNU_DATE=gdate fi -if [[ $FORCE_RELEASE != "" || $git_tag == v* ]]; then +if [[ $FORCE_RELEASE != "" || $git_tag =~ ^v[0-9.]+$ ]]; then echo -n +elif [[ $git_tag =~ ^v[0-9.]+-pre. ]]; then + echo -n "pre.${git_tag#*-pre.}" else # Use last commit date rather than build date to avoid ending up with builds for # different platforms having different version strings (and therefore producing different bytecode)