|
2 | 2 | set -euo pipefail |
3 | 3 |
|
4 | 4 | REPO_ROOT="$(dirname "$0")"/.. |
| 5 | +# shellcheck source=scripts/common.sh |
| 6 | +source "${REPO_ROOT}/scripts/common.sh" |
| 7 | + |
5 | 8 | cd "$REPO_ROOT" |
6 | 9 | version=$(scripts/get_version.sh) |
7 | 10 | commit_hash=$(git rev-parse --short=8 HEAD) |
8 | | -commit_date=$(git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./') |
9 | 11 |
|
10 | | -# File exists and has zero size -> not a prerelease |
11 | | -if [[ -e prerelease.txt && ! -s prerelease.txt ]]; then |
12 | | - version_string="$version" |
| 12 | +if [[ -e prerelease.txt ]]; then |
| 13 | + prerelease_suffix=$(cat prerelease.txt) |
| 14 | + if [[ $prerelease_suffix == "" ]]; then |
| 15 | + # File exists and has zero size -> not a prerelease |
| 16 | + version_string="$version" |
| 17 | + elif [[ $prerelease_suffix == pre.* ]]; then |
| 18 | + # Tagged prerelease -> unambiguous, so commit hash not needed |
| 19 | + version_string="${version}-${prerelease_suffix}" |
| 20 | + else |
| 21 | + # Nightly/develop/other prerelease -> include commit hash |
| 22 | + version_string="${version}-${prerelease_suffix}-${commit_hash}" |
| 23 | + fi |
13 | 24 | else |
| 25 | + # Nightly/develop/other prerelease -> include commit hash + default prerelease suffix |
| 26 | + commit_date=$(TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="%cd") |
14 | 27 | version_string="${version}-nightly-${commit_date}-${commit_hash}" |
15 | 28 | fi |
16 | 29 |
|
| 30 | +# The only purpose of commit_hash.txt is to make it possible to build the compiler without git. |
| 31 | +# It is not meant as an override of the real hash. |
| 32 | +[[ ! -e commit_hash.txt ]] || \ |
| 33 | + fail "commit_hash.txt is present in the repository root, but will not be used to override the commit hash for the source package." |
| 34 | + |
17 | 35 | TEMPDIR=$(mktemp -d -t "solc-src-tarball-XXXXXX") |
18 | 36 | SOLDIR="${TEMPDIR}/solidity_${version_string}/" |
19 | 37 | mkdir "$SOLDIR" |
|
0 commit comments