Skip to content

Commit

Permalink
tools: automate v8 patch update
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Apr 17, 2023
1 parent b8c7a1e commit 03b4a51
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ jobs:
cat temp-output
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
rm temp-output
- id: v8
subsystem: deps
label: dependencies
run: |
./tools/dep_updaters/update-v8-patch.sh > temp-output
cat temp-output
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
rm temp-output
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
Expand Down
75 changes: 75 additions & 0 deletions tools/dep_updaters/update-v8-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/sh
set -e
# Shell script to update v8 patch update

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
DEPS_DIR="$BASE_DIR/deps"

CURRENT_MAJOR_VERSION=$(grep "#define V8_MAJOR_VERSION" "$DEPS_DIR/v8/include/v8-version.h" | cut -d ' ' -f3)
CURRENT_MINOR_VERSION=$(grep "#define V8_MINOR_VERSION" "$DEPS_DIR/v8/include/v8-version.h" | cut -d ' ' -f3)
CURRENT_BUILD_VERSION=$(grep "#define V8_BUILD_NUMBER" "$DEPS_DIR/v8/include/v8-version.h" | cut -d ' ' -f3)
CURRENT_PATCH_VERSION=$(grep "#define V8_PATCH_LEVEL" "$DEPS_DIR/v8/include/v8-version.h" | cut -d ' ' -f3)

CURRENT_VERSION_NO_PATCH="$CURRENT_MAJOR_VERSION.$CURRENT_MINOR_VERSION.$CURRENT_BUILD_VERSION"

NEW_VERSION=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://chromium.googlesource.com/v8/v8 "$CURRENT_VERSION_NO_PATCH.*" | tail -n1 | cut -d '/' -f3)

LATEST_PATCH_VERSION=$(echo "$NEW_VERSION" | cut -d '.' -f4)

if [ -z "$LATEST_PATCH_VERSION" ]; then
echo "Skipped because latest patch is not available."
exit 0
fi

echo "Comparing current patch version $CURRENT_PATCH_VERSION with latest patch $LATEST_PATCH_VERSION"

if [ "$CURRENT_PATCH_VERSION" = "$LATEST_PATCH_VERSION" ]; then
echo "Skipped because v8 is on the latest version."
exit 0
fi

NEW_VERSION="$CURRENT_VERSION_NO_PATCH.$LATEST_PATCH_VERSION"

CURRENT_VERSION="$CURRENT_VERSION_NO_PATCH.$CURRENT_PATCH_VERSION"

WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')

cleanup () {
EXIT_CODE=$?
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
exit $EXIT_CODE
}

trap cleanup INT TERM EXIT

cd "$WORKSPACE"

echo "Cloning v8 repository..."

git clone https://chromium.googlesource.com/v8/v8

cd v8

PATCH_DIFF="v8_patch.diff"

echo "Generating patch file..."

git format-patch "$CURRENT_VERSION...$NEW_VERSION" --stdout > "$WORKSPACE/$PATCH_DIFF"

cd "$DEPS_DIR/v8"

echo "Applying patch file..."

git apply "$WORKSPACE/$PATCH_DIFF"

echo "All done!"
echo ""
echo "Please git add v8, commit the new version:"
echo ""
echo "$ git add -A deps/v8"
echo "$ git commit -m \"deps: update v8 to $NEW_VERSION\""
echo ""

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"

0 comments on commit 03b4a51

Please sign in to comment.