Skip to content
Merged
16 changes: 6 additions & 10 deletions .circleci/config.yml
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that tagged prereleases will skip most of the CI in solc-bin, because compare_bytecode_reports.sh filters out anything that's not a release. I think it's fine, because they are supposed to have passed CI checks in the solidity repo and messing this up is not as big of a deal as with a full release. Still, one thing that would be useful to keep is the sanity check that the filename matches the output of solc --version. This check now sits in validate_reported_version() in bytecode_reports_for_modified_binaries.sh. We should extract it into a separate PR check that runs on all binaries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds to me like it's almost easier to adapt the regex to allow for prereleases as well:)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's an option too.

Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,12 @@ commands:
# --------------------------------------------------------------------------
# Build Commands

setup_prerelease_commit_hash:
setup_prerelease:
steps:
- run:
name: Store commit hash and prerelease
name: Store prerelease suffix
command: |
if [[ $CIRCLE_BRANCH == release || -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
Copy link
Collaborator Author

@cameel cameel Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure if there was a reason we were creating commit_hash.txt here, but it seems completely unnecessary now. It appeared a long time ago in #3470, with no explanation, even though the logic for getting it from git already existed in buildinfo.cmake at that time. Then it spread to other places when this logic was copied.

"scripts/prerelease_suffix.sh" nightly "$CIRCLE_TAG" > prerelease.txt

install_and_check_minimum_requirements:
parameters:
Expand Down Expand Up @@ -1006,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
Expand Down Expand Up @@ -1115,7 +1111,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
Expand Down Expand Up @@ -1225,7 +1221,7 @@ jobs:
<<: *base_ubuntu2404_small
steps:
- checkout
- setup_prerelease_commit_hash
- setup_prerelease
- run:
name: Install build system dependencies
command: |
Expand Down
6 changes: 4 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ 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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prerelease_file = '../prerelease.txt' would have been nice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally didn't want to introduce new variables here since I'm not sure if these don't become visible as settings.

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
Expand Down
6 changes: 4 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 2 additions & 13 deletions scripts/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,12 @@ prerelease_source="${1:-ci}"

cd "${ROOTDIR}"

if [[ $CIRCLE_BRANCH == release || -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

if [[ -n $CIRCLE_SHA1 ]]; then
echo -n "$CIRCLE_SHA1" > commit_hash.txt
fi
"${ROOTDIR}/scripts/prerelease_suffix.sh" "$prerelease_source" "$CIRCLE_TAG" > prerelease.txt

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
Expand Down
12 changes: 1 addition & 11 deletions scripts/ci/build_emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +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
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
if [[ -n $CIRCLE_SHA1 ]]; then
echo -n "$CIRCLE_SHA1" > commit_hash.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.
Expand Down
15 changes: 1 addition & 14 deletions scripts/ci/build_win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
26 changes: 22 additions & 4 deletions scripts/create_source_tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@
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)
commit_date=$(git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./')

# File exists and has zero size -> not a prerelease
if [[ -e prerelease.txt && ! -s prerelease.txt ]]; then
version_string="$version"
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

# 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"
Expand Down
29 changes: 29 additions & 0 deletions scripts/prerelease_suffix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/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[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)
# 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