Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3bf2bd4

Browse filesBrowse files
marco-ippolitoMoLow
authored andcommitted
tools: automate icu-small update
PR-URL: #47727 Refs: nodejs/security-wg#828 Reviewed-By: Steven R Loomis <srl295@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent b80e006 commit 3bf2bd4
Copy full SHA for 3bf2bd4

File tree

Expand file treeCollapse file tree

4 files changed

+95
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+95
-0
lines changed
Open diff view settings
Collapse file

‎.github/workflows/tools.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tools.yml
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ on:
2424
- doc
2525
- eslint
2626
- googletest
27+
- icu
2728
- libuv
2829
- lint-md-dependencies
2930
- llhttp
@@ -36,6 +37,9 @@ on:
3637
- undici
3738
- uvwasi
3839

40+
env:
41+
PYTHON_VERSION: '3.11'
42+
3943
permissions:
4044
contents: read
4145

@@ -254,11 +258,24 @@ jobs:
254258
cat temp-output
255259
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
256260
rm temp-output
261+
- id: icu
262+
subsystem: deps
263+
label: dependencies, test
264+
run: |
265+
./tools/dep_updaters/update-icu.sh > temp-output
266+
cat temp-output
267+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
268+
rm temp-output
257269
steps:
258270
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
259271
if: github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id
260272
with:
261273
persist-credentials: false
274+
- name: Set up Python ${{ env.PYTHON_VERSION }}
275+
if: matrix.id == 'icu' && (github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id)
276+
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
277+
with:
278+
python-version: ${{ env.PYTHON_VERSION }}
262279
- run: ${{ matrix.run }}
263280
if: github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id
264281
env:
Collapse file

‎doc/contributing/maintaining/maintaining-icu.md‎

Copy file name to clipboardExpand all lines: doc/contributing/maintaining/maintaining-icu.md
+3Lines changed: 3 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ Node.js is built.
101101
102102
## How to upgrade ICU
103103
104+
> The script `tools/dep_updaters/update-icu.sh` automates
105+
> this process.
106+
104107
* Make sure your Node.js workspace is clean (`git status`
105108
should be sufficient).
106109
* Configure Node.js with the specific [ICU version](http://site.icu-project.org/download)
Collapse file

‎tools/dep_updaters/update-icu.sh‎

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

‎tools/icu/shrink-icu-src.py‎

Copy file name to clipboard
100644100755
Expand all lines: tools/icu/shrink-icu-src.py
File mode changed.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.