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 30c667e

Browse filesBrowse files
marco-ippolitoRafaelGSS
authored andcommitted
tools: automate brotli update
PR-URL: #47205 Refs: nodejs/security-wg#828 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Adrian Estrada <edsadr@gmail.com>
1 parent 83791e5 commit 30c667e
Copy full SHA for 30c667e

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎.github/workflows/tools.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tools.yml
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ jobs:
159159
cat temp-output
160160
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
161161
rm temp-output
162+
- id: brotli
163+
subsystem: deps
164+
label: dependencies
165+
run: |
166+
./tools/dep_updaters/update-brotli.sh > temp-output
167+
cat temp-output
168+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
169+
rm temp-output
162170
steps:
163171
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
164172
with:
Collapse file
+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 brotli in the source tree to a specific version
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
DEPS_DIR="$BASE_DIR/deps"
7+
8+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
9+
[ -x "$NODE" ] || NODE=$(command -v node)
10+
11+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
12+
const res = await fetch('https://api.github.com/repos/google/brotli/releases/latest');
13+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
14+
const { tag_name } = await res.json();
15+
console.log(tag_name.replace('v', ''));
16+
EOF
17+
)"
18+
19+
VERSION_HEX=$(grep "#define BROTLI_VERSION" ./deps/brotli/c/common/version.h | sed 's/.* //')
20+
21+
major=$(( ($VERSION_HEX >> 24) & 0xff ))
22+
minor=$(( ($VERSION_HEX >> 12) & 0xfff ))
23+
patch=$(( $VERSION_HEX & 0xfff ))
24+
CURRENT_VERSION="${major}.${minor}.${patch}"
25+
26+
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
27+
28+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
29+
echo "Skipped because brotli is on the latest version."
30+
exit 0
31+
fi
32+
33+
echo "Making temporary workspace"
34+
35+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
36+
37+
cleanup () {
38+
EXIT_CODE=$?
39+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
40+
exit $EXIT_CODE
41+
}
42+
43+
trap cleanup INT TERM EXIT
44+
45+
cd "$WORKSPACE"
46+
47+
BROTLI_TARBALL="v$NEW_VERSION.tar.gz"
48+
49+
echo "Fetching brotli source archive"
50+
curl -sL -o "$BROTLI_TARBALL" "https://github.com/google/brotli/archive/$BROTLI_TARBALL"
51+
gzip -dc "$BROTLI_TARBALL" | tar xf -
52+
rm "$BROTLI_TARBALL"
53+
mv "brotli-$NEW_VERSION" "brotli"
54+
55+
echo "Copying existing gyp file"
56+
cp "$DEPS_DIR/brotli/brotli.gyp" "$WORKSPACE/brotli"
57+
58+
echo "Deleting existing brotli"
59+
rm -rf "$DEPS_DIR/brotli"
60+
mkdir "$DEPS_DIR/brotli"
61+
62+
echo "Update c and LICENSE"
63+
mv "$WORKSPACE/brotli/c" "$WORKSPACE/brotli/LICENSE" "$WORKSPACE/brotli/brotli.gyp" "$DEPS_DIR/brotli"
64+
65+
echo "All done!"
66+
echo ""
67+
echo "Please git add brotli, commit the new version:"
68+
echo ""
69+
echo "$ git add -A deps/brotli"
70+
echo "$ git commit -m \"deps: update brotli 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"

0 commit comments

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