github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/.github/generate_change_log.sh (about)

     1  #!/usr/bin/env bash
     2  checksum() {
     3      echo $(sha256sum $@ | awk '{print $1}')
     4  }
     5  change_log_file="./CHANGELOG.md"
     6  version="## $@"
     7  version_prefix="## v"
     8  start=0
     9  CHANGE_LOG=""
    10  while read line; do
    11      if [[ $line == *"$version"* ]]; then
    12          start=1
    13          continue
    14      fi
    15      if [[ $line == *"$version_prefix"* ]] && [ $start == 1 ]; then
    16          break;
    17      fi
    18      if [ $start == 1 ] && [[ $line != "" ]]; then
    19          CHANGE_LOG+="$line\n"
    20      fi
    21  done < ${change_log_file}
    22  LINUX_BIN_SUM="$(checksum ./linux/bytomd)"
    23  MAC_BIN_SUM="$(checksum ./macos/bytomd)"
    24  WINDOWS_BIN_SUM="$(checksum ./windows/bytomd)"
    25  OUTPUT=$(cat <<-END
    26  ## Changelog\n
    27  ${CHANGE_LOG}\n
    28  ## Assets\n
    29  |    Assets    | Sha256 Checksum  |\n
    30  | :-----------: |------------|\n
    31  | bytomd_linux | ${LINUX_BIN_SUM} |\n
    32  | bytomd_mac  | ${MAC_BIN_SUM} |\n
    33  | bytomd_windows  | ${WINDOWS_BIN_SUM} |\n
    34  END
    35  )
    36  
    37  echo -e ${OUTPUT}