Skip to content

Commit 7955ef1

Browse files
authored
tools: add temporal updater
PR-URL: nodejs#60828 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
1 parent ae62b36 commit 7955ef1

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

.github/workflows/tools.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ on:
3838
- root-certificates
3939
- simdjson
4040
- sqlite
41+
- temporal
4142
- undici
4243
- uvwasi
4344
- zlib
@@ -255,6 +256,14 @@ jobs:
255256
cat temp-output
256257
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
257258
rm temp-output
259+
- id: temporal
260+
subsystem: deps
261+
label: dependencies
262+
run: |
263+
./tools/dep_updaters/update-temporal.sh > temp-output
264+
cat temp-output
265+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
266+
rm temp-output
258267
- id: undici
259268
subsystem: deps
260269
label: dependencies
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update temporal in the source tree to specific version
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
7+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
8+
[ -x "$NODE" ] || NODE=$(command -v node)
9+
10+
# shellcheck disable=SC1091
11+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
12+
13+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
14+
const res = await fetch('https://api.github.com/repos/boa-dev/temporal/releases/latest');
15+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
16+
const { tag_name } = await res.json();
17+
console.log(tag_name.replace('v', ''));
18+
EOF
19+
)"
20+
21+
CURRENT_VERSION=$(grep -m 1 version ./deps/temporal/Cargo.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
22+
23+
# This function exit with 0 if new version and current version are the same
24+
compare_dependency_version "temporal" "$NEW_VERSION" "$CURRENT_VERSION"
25+
26+
echo "Making temporary workspace"
27+
28+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
29+
30+
cleanup () {
31+
EXIT_CODE=$?
32+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
33+
exit $EXIT_CODE
34+
}
35+
36+
trap cleanup INT TERM EXIT
37+
38+
TEMPORAL_TARBALL="$NEW_VERSION.tar.gz"
39+
40+
cd "$WORKSPACE"
41+
42+
curl -sL -o "$TEMPORAL_TARBALL" "https://github.com/boa-dev/temporal/archive/refs/tags/v$NEW_VERSION.tar.gz"
43+
log_and_verify_sha256sum "temporal" "$TEMPORAL_TARBALL"
44+
45+
gzip -dc "$TEMPORAL_TARBALL" | tar xf -
46+
47+
rm "$TEMPORAL_TARBALL"
48+
49+
mv "temporal-$NEW_VERSION" temporal
50+
51+
rm -rf "$WORKSPACE/temporal/.github"
52+
53+
echo "Copying existing gyp files"
54+
cp "$BASE_DIR/deps/temporal/temporal_capi/temporal_capi.gyp" "$WORKSPACE/temporal/temporal_capi"
55+
56+
echo "Applying dependency update"
57+
rm -rf "$BASE_DIR/deps/temporal"
58+
mv "$WORKSPACE/temporal" "$BASE_DIR/deps/temporal"
59+
60+
echo "All done!"
61+
echo ""
62+
echo "Please git add temporal and commit the new version:"
63+
echo ""
64+
echo "$ git add -A deps/temporal"
65+
echo "$ git commit -m \"deps: update temporal to $NEW_VERSION\""
66+
echo ""
67+
68+
# The last line of the script should always print the new version,
69+
# as we need to add it to $GITHUB_ENV variable.
70+
echo "NEW_VERSION=$NEW_VERSION"

0 commit comments

Comments
 (0)