• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2set -e
3# Shell script to update icu in the source tree to a specific version
4
5BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6DEPS_DIR="$BASE_DIR/deps"
7TOOLS_DIR="$BASE_DIR/tools"
8
9[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
10[ -x "$NODE" ] || NODE=$(command -v node)
11
12NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
13const res = await fetch('https://api.github.com/repos/unicode-org/icu/releases/latest');
14if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
15const { tag_name } = await res.json();
16console.log(tag_name.replace('release-', '').replace('-','.'));
17EOF
18)"
19
20ICU_VERSION_H="$DEPS_DIR/icu-small/source/common/unicode/uvernum.h"
21
22CURRENT_VERSION="$(grep "#define U_ICU_VERSION " "$ICU_VERSION_H" | cut -d'"' -f2)"
23
24echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
25
26if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
27  echo "Skipped because icu is on the latest version."
28  exit 0
29fi
30
31DASHED_NEW_VERSION=$(echo "$NEW_VERSION" | sed 's/\./-/g')
32
33LOW_DASHED_NEW_VERSION=$(echo "$NEW_VERSION" | sed 's/\./_/g')
34
35NEW_VERSION_TGZ="icu4c-${LOW_DASHED_NEW_VERSION}-src.tgz"
36
37NEW_VERSION_TGZ_URL="https://github.com/unicode-org/icu/releases/download/release-${DASHED_NEW_VERSION}/$NEW_VERSION_TGZ"
38
39NEW_VERSION_MD5="https://github.com/unicode-org/icu/releases/download/release-${DASHED_NEW_VERSION}/icu4c-${LOW_DASHED_NEW_VERSION}-src.md5"
40
41./configure --with-intl=full-icu --with-icu-source="$NEW_VERSION_TGZ_URL"
42
43"$TOOLS_DIR/icu/shrink-icu-src.py"
44
45rm -rf "$DEPS_DIR/icu"
46
47CHECKSUM=$(curl -sL "$NEW_VERSION_MD5" | grep "$NEW_VERSION_TGZ" | grep -v "\.asc$" | awk '{print $1}')
48
49GENERATED_CHECKSUM=$( curl -sL "$NEW_VERSION_TGZ_URL" | md5sum | cut -d ' ' -f1)
50
51echo "Comparing checksums: deposited $CHECKSUM with $GENERATED_CHECKSUM"
52
53if [ "$CHECKSUM" != "$GENERATED_CHECKSUM" ]; then
54  echo "Skipped because checksums do not match."
55  exit 0
56fi
57
58perl -i -pe "s|\"url\": .*|\"url\": \"$NEW_VERSION_TGZ_URL\",|" "$TOOLS_DIR/icu/current_ver.dep"
59
60perl -i -pe "s|\"md5\": .*|\"md5\": \"$CHECKSUM\"|" "$TOOLS_DIR/icu/current_ver.dep"
61
62rm -rf out "$DEPS_DIR/icu" "$DEPS_DIR/icu4c*"
63
64echo "All done!"
65echo ""
66echo "Please git add icu, commit the new version:"
67echo ""
68echo "$ git add -A deps/icu-small"
69echo "$ git add tools/icu/current_ver.dep"
70echo "$ git commit -m \"deps: update icu to $NEW_VERSION\""
71echo ""
72
73# The last line of the script should always print the new version,
74# as we need to add it to $GITHUB_ENV variable.
75echo "NEW_VERSION=$NEW_VERSION"
76