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 ecce647

Browse filesBrowse files
tony-gotargos
authored andcommitted
tools: refactor dep_updaters
PR-URL: #46488 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent db2ace1 commit ecce647
Copy full SHA for ecce647

File tree

Expand file treeCollapse file tree

5 files changed

+100
-55
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+100
-55
lines changed
Open diff view settings
Collapse file

‎.github/workflows/tools.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tools.yml
+16-30Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ jobs:
2121
subsystem: tools
2222
label: tools
2323
run: |
24-
NEW_VERSION=$(npm view eslint dist-tags.latest)
25-
CURRENT_VERSION=$(node -p "require('./tools/node_modules/eslint/package.json').version")
26-
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
27-
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
28-
./tools/dep_updaters/update-eslint.sh
29-
fi
24+
./tools/dep_updaters/update-eslint.sh > temp-output
25+
cat temp-output
26+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
27+
rm temp-output
3028
- id: corepack
3129
subsystem: deps
3230
label: dependencies
@@ -81,12 +79,10 @@ jobs:
8179
subsystem: deps,test
8280
label: test
8381
run: |
84-
NEW_VERSION=$(npm view postject dist-tags.latest)
85-
CURRENT_VERSION=$(node -p "require('./test/fixtures/postject-copy/node_modules/postject/package.json').version")
86-
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
87-
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
88-
./tools/dep_updaters/update-postject.sh
89-
fi
82+
./tools/dep_updaters/update-postject.sh > temp-output
83+
cat temp-output
84+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
85+
rm temp-output
9086
- id: base64
9187
subsystem: deps
9288
label: dependencies
@@ -122,28 +118,18 @@ jobs:
122118
subsystem: deps
123119
label: dependencies
124120
run: |
125-
NEW_VERSION=$(gh api repos/libuv/libuv/releases/latest -q '.tag_name|ltrimstr("v")')
126-
VERSION_H="./deps/uv/include/uv/version.h"
127-
CURRENT_MAJOR_VERSION=$(grep "#define UV_VERSION_MAJOR" $VERSION_H | sed -n "s/^.*MAJOR \(.*\)/\1/p")
128-
CURRENT_MINOR_VERSION=$(grep "#define UV_VERSION_MINOR" $VERSION_H | sed -n "s/^.*MINOR \(.*\)/\1/p")
129-
CURRENT_PATCH_VERSION=$(grep "#define UV_VERSION_PATCH" $VERSION_H | sed -n "s/^.*PATCH \(.*\)/\1/p")
130-
CURRENT_SUFFIX_VERSION=$(grep "#define UV_VERSION_SUFFIX" $VERSION_H | sed -n "s/^.*SUFFIX \"\(.*\)\"/\1/p")
131-
SUFFIX_STRING=$([[ -z "$CURRENT_SUFFIX_VERSION" ]] && echo "" || echo "-$CURRENT_SUFFIX_VERSION")
132-
CURRENT_VERSION="$CURRENT_MAJOR_VERSION.$CURRENT_MINOR_VERSION.$CURRENT_PATCH_VERSION$SUFFIX_STRING"
133-
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
134-
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
135-
./tools/dep_updaters/update-libuv.sh "$NEW_VERSION"
136-
fi
121+
./tools/dep_updaters/update-libuv.sh > temp-output
122+
cat temp-output
123+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
124+
rm temp-output
137125
- id: simdutf
138126
subsystem: deps
139127
label: dependencies
140128
run: |
141-
NEW_VERSION=$(gh api repos/simdutf/simdutf/releases/latest -q '.tag_name|ltrimstr("v")')
142-
CURRENT_VERSION=$(grep "#define SIMDUTF_VERSION" ./deps/simdutf/simdutf.h | sed -n "s/^.*VERSION \(.*\)/\1/p")
143-
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
144-
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
145-
./tools/dep_updaters/update-simdutf.sh "$NEW_VERSION"
146-
fi
129+
./tools/dep_updaters/update-simdutf.sh > temp-output
130+
cat temp-output
131+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
132+
rm temp-output
147133
- id: ada
148134
subsystem: deps
149135
label: dependencies
Collapse file

‎tools/dep_updaters/update-eslint.sh‎

Copy file name to clipboardExpand all lines: tools/dep_updaters/update-eslint.sh
+18-5Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,27 @@
77

88
set -ex
99

10+
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
11+
12+
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
13+
[ -x "$NODE" ] || NODE=$(command -v node)
14+
NPM="$ROOT/deps/npm/bin/npm-cli.js"
15+
16+
NEW_VERSION=$("$NODE" "$NPM" view eslint dist-tags.latest)
17+
CURRENT_VERSION=$("$NODE" -p "require('./tools/node_modules/eslint/package.json').version")
18+
19+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
20+
echo "Skipped because ESlint is on the latest version."
21+
exit 0
22+
fi
23+
1024
cd "$( dirname "$0" )" || exit
1125
rm -rf ../node_modules/eslint
1226
(
1327
rm -rf eslint-tmp
1428
mkdir eslint-tmp
1529
cd eslint-tmp || exit
1630

17-
ROOT="$PWD/../../.."
18-
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
19-
[ -x "$NODE" ] || NODE=$(command -v node)
20-
NPM="$ROOT/deps/npm/bin/npm-cli.js"
21-
2231
"$NODE" "$NPM" init --yes
2332

2433
"$NODE" "$NPM" install \
@@ -63,3 +72,7 @@ rm -rf ../node_modules/eslint
6372

6473
mv eslint-tmp/node_modules/eslint ../node_modules/eslint
6574
rm -rf eslint-tmp/
75+
76+
# The last line of the script should always print the new version,
77+
# as we need to add it to $GITHUB_ENV variable.
78+
echo "NEW_VERSION=$NEW_VERSION"
Collapse file

‎tools/dep_updaters/update-libuv.sh‎

Copy file name to clipboardExpand all lines: tools/dep_updaters/update-libuv.sh
+28-7Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,29 @@ set -e
44

55
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
66
DEPS_DIR="$BASE_DIR/deps"
7-
LIBUV_VERSION=$1
7+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
8+
[ -x "$NODE" ] || NODE=$(command -v node)
89

9-
if [ "$#" -le 0 ]; then
10-
echo "Error: please provide an libuv version to update to"
11-
echo " e.g. $0 1.44.2"
12-
exit 1
10+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
11+
const res = await fetch('https://api.github.com/repos/libuv/libuv/releases/latest');
12+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
13+
const { tag_name } = await res.json();
14+
console.log(tag_name.replace('v', ''));
15+
EOF
16+
)"
17+
18+
VERSION_H="$DEPS_DIR/uv/include/uv/version.h"
19+
CURRENT_MAJOR_VERSION=$(grep "#define UV_VERSION_MAJOR" "$VERSION_H" | sed -n "s/^.*MAJOR \(.*\)/\1/p")
20+
CURRENT_MINOR_VERSION=$(grep "#define UV_VERSION_MINOR" "$VERSION_H" | sed -n "s/^.*MINOR \(.*\)/\1/p")
21+
CURRENT_PATCH_VERSION=$(grep "#define UV_VERSION_PATCH" "$VERSION_H" | sed -n "s/^.*PATCH \(.*\)/\1/p")
22+
CURRENT_IS_RELEASE=$(grep "#define UV_VERSION_IS_RELEASE" "$VERSION_H" | sed -n "s/^.*RELEASE \(.*\)/\1/p")
23+
CURRENT_SUFFIX_VERSION=$(grep "#define UV_VERSION_SUFFIX" "$VERSION_H" | sed -n "s/^.*SUFFIX \"\(.*\)\"/\1/p")
24+
SUFFIX_STRING=$([ "$CURRENT_IS_RELEASE" = 1 ] || [ -z "$CURRENT_SUFFIX_VERSION" ] && echo "" || echo "-$CURRENT_SUFFIX_VERSION")
25+
CURRENT_VERSION="$CURRENT_MAJOR_VERSION.$CURRENT_MINOR_VERSION.$CURRENT_PATCH_VERSION$SUFFIX_STRING"
26+
27+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
28+
echo "Skipped because libuv is on the latest version."
29+
exit 0
1330
fi
1431

1532
echo "Making temporary workspace..."
@@ -27,7 +44,7 @@ trap cleanup INT TERM EXIT
2744
cd "$WORKSPACE"
2845

2946
echo "Fetching libuv source archive..."
30-
curl -sL "https://api.github.com/repos/libuv/libuv/tarball/v$LIBUV_VERSION" | tar xzf -
47+
curl -sL "https://api.github.com/repos/libuv/libuv/tarball/v$NEW_VERSION" | tar xzf -
3148
mv libuv-libuv-* uv
3249

3350
echo "Replacing existing libuv (except GYP build files)"
@@ -40,5 +57,9 @@ echo ""
4057
echo "Please git add uv, commit the new version:"
4158
echo ""
4259
echo "$ git add -A deps/uv"
43-
echo "$ git commit -m \"deps: update libuv to $LIBUV_VERSION\""
60+
echo "$ git commit -m \"deps: update libuv to $NEW_VERSION\""
4461
echo ""
62+
63+
# The last line of the script should always print the new version,
64+
# as we need to add it to $GITHUB_ENV variable.
65+
echo "NEW_VERSION=$NEW_VERSION"
Collapse file

‎tools/dep_updaters/update-postject.sh‎

Copy file name to clipboardExpand all lines: tools/dep_updaters/update-postject.sh
+17-5Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@
77

88
set -ex
99

10+
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
11+
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
12+
[ -x "$NODE" ] || NODE=$(command -v node)
13+
NPM="$ROOT/deps/npm/bin/npm-cli.js"
14+
15+
NEW_VERSION=$("$NODE" "$NPM" view postject dist-tags.latest)
16+
CURRENT_VERSION=$("$NODE" -p "require('./test/fixtures/postject-copy/node_modules/postject/package.json').version")
17+
18+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
19+
echo "Skipped because Postject is on the latest version."
20+
exit 0
21+
fi
22+
1023
cd "$( dirname "$0" )/../.." || exit
1124
rm -rf test/fixtures/postject-copy
1225
mkdir test/fixtures/postject-copy
1326
cd test/fixtures/postject-copy || exit
1427

15-
ROOT="$PWD/../../.."
16-
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
17-
[ -x "$NODE" ] || NODE=$(command -v node)
18-
NPM="$ROOT/deps/npm/bin/npm-cli.js"
19-
2028
"$NODE" "$NPM" init --yes
2129

2230
"$NODE" "$NPM" install --no-bin-links --ignore-scripts postject
@@ -27,3 +35,7 @@ rm -rf deps/postject
2735
mkdir deps/postject
2836
cp test/fixtures/postject-copy/node_modules/postject/LICENSE deps/postject
2937
cp test/fixtures/postject-copy/node_modules/postject/dist/postject-api.h deps/postject
38+
39+
# The last line of the script should always print the new version,
40+
# as we need to add it to $GITHUB_ENV variable.
41+
echo "NEW_VERSION=$NEW_VERSION"
Collapse file

‎tools/dep_updaters/update-simdutf.sh‎

Copy file name to clipboardExpand all lines: tools/dep_updaters/update-simdutf.sh
+21-8Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ set -e
44

55
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
66
DEPS_DIR="$BASE_DIR/deps"
7-
SIMDUTF_VERSION=$1
7+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
8+
[ -x "$NODE" ] || NODE=$(command -v node)
89

9-
if [ "$#" -le 0 ]; then
10-
echo "Error: please provide an simdutf version to update to"
11-
echo " e.g. $0 2.0.3"
12-
exit 1
10+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
11+
const res = await fetch('https://api.github.com/repos/simdutf/simdutf/releases/latest');
12+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
13+
const { tag_name } = await res.json();
14+
console.log(tag_name.replace('v', ''));
15+
EOF
16+
)"
17+
CURRENT_VERSION=$(grep "#define SIMDUTF_VERSION" "$DEPS_DIR/simdutf/simdutf.h" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")
18+
19+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
20+
echo "Skipped because simdutf is on the latest version."
21+
exit 0
1322
fi
1423

1524
echo "Making temporary workspace..."
@@ -24,8 +33,8 @@ cleanup () {
2433

2534
trap cleanup INT TERM EXIT
2635

27-
SIMDUTF_REF="v$SIMDUTF_VERSION"
28-
SIMDUTF_ZIP="simdutf-$SIMDUTF_VERSION.zip"
36+
SIMDUTF_REF="v$NEW_VERSION"
37+
SIMDUTF_ZIP="simdutf-$NEW_VERSION.zip"
2938
SIMDUTF_LICENSE="LICENSE-MIT"
3039

3140
cd "$WORKSPACE"
@@ -48,5 +57,9 @@ echo ""
4857
echo "Please git add simdutf, commit the new version:"
4958
echo ""
5059
echo "$ git add -A deps/simdutf"
51-
echo "$ git commit -m \"deps: update simdutf to $SIMDUTF_VERSION\""
60+
echo "$ git commit -m \"deps: update simdutf to $NEW_VERSION\""
5261
echo ""
62+
63+
# The last line of the script should always print the new version,
64+
# as we need to add it to $GITHUB_ENV variable.
65+
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.