diff --git a/CHANGELOG.md b/CHANGELOG.md index 9014ba7b..2bc4f520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fix echo does not break test execution results - Add bashunit facade to enable custom assertions - Document how to verify the `sha256sum` of the final executable +- Generate checksum on build - Enable display execution time on macOS with `SHOW_EXECUTION_TIME` - Support for displaying the clock without `perl` (for non-macOS) - Add `-l|--log-junit ` option diff --git a/build.sh b/build.sh index 022c324b..7400aa49 100755 --- a/build.sh +++ b/build.sh @@ -1,16 +1,43 @@ #!/bin/bash -mkdir -p bin +source src/check_os.sh -output_file="bin/bashunit" +function generate_bin() { + local output_file=$1 + echo '#!/usr/bin/env bash' > bin/temp.sh + + echo "Generating bashunit in the 'bin' folder..." + cat src/*.sh >> bin/temp.sh + cat bashunit >> bin/temp.sh + grep -v '^source' bin/temp.sh > "$output_file" + rm bin/temp.sh + chmod u+x "$output_file" +} + +function generate_checksum() { + if [[ "$_OS" == "Windows" ]]; then + return + fi + + local file=$1 + if [[ "$_OS" == "OSX" ]]; then + checksum=$(shasum -a 256 "$file") + elif [[ "$_OS" == "Linux" ]]; then + checksum=$(sha256sum "$file") + fi -echo '#!/usr/bin/env bash' > bin/temp.sh + echo "$checksum" > bin/checksum + echo "$checksum" +} + +######################## +######### MAIN ######### +######################## + +mkdir -p bin +output_file="bin/bashunit" -echo "Generating bashunit in the 'bin' folder..." -cat src/*.sh >> bin/temp.sh -cat bashunit >> bin/temp.sh -grep -v '^source' bin/temp.sh > "$output_file" -rm bin/temp.sh -chmod u+x "$output_file" +generate_bin "$output_file" +generate_checksum "$output_file" echo "⚡️Build completed⚡️"