Skip to content

Commit f8da622

Browse files
feat: created action with cache
1 parent c03650b commit f8da622

File tree

4 files changed

+101
-83
lines changed

4 files changed

+101
-83
lines changed

.github/workflows/tools.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,6 @@ jobs:
252252
cat temp-output
253253
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
254254
rm temp-output
255-
- id: v8
256-
subsystem: deps
257-
label: dependencies
258-
run: |
259-
./tools/dep_updaters/update-v8-patch.sh > temp-output
260-
cat temp-output
261-
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
262-
rm temp-output
263255
steps:
264256
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
265257
if: github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id

.github/workflows/update-v8.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: V8 update
2+
on:
3+
schedule:
4+
# Run once a week at 00:05 AM UTC on Sunday.
5+
- cron: 5 0 * * 0
6+
7+
workflow_dispatch:
8+
inputs:
9+
id:
10+
description: The ID of the job to run
11+
required: true
12+
default: all
13+
type: choice
14+
options:
15+
- all
16+
- minor
17+
# preparing for v8 major
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
v8-update:
23+
if: github.repository == 'nodejs/node'
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false # Prevent other jobs from aborting if one fails
27+
matrix:
28+
include:
29+
- id: minor
30+
subsystem: deps
31+
label: dependencies
32+
run: |
33+
./tools/dep_updaters/update-v8-minor.sh > temp-output
34+
cat temp-output
35+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
36+
rm temp-output
37+
steps:
38+
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
39+
if: github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id
40+
with:
41+
persist-credentials: false
42+
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
43+
with:
44+
path: ~/.update-v8/v8
45+
- run: ${{ matrix.run }}
46+
if: github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
49+
- name: Generate commit message if not set
50+
if: env.COMMIT_MSG == '' && (github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id)
51+
run: |
52+
echo "COMMIT_MSG=${{ matrix.subsystem }}: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}" >> "$GITHUB_ENV"
53+
- uses: gr2m/create-or-update-pull-request-action@77596e3166f328b24613f7082ab30bf2d93079d5
54+
if: github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id
55+
# Creates a PR or update the Action's existing PR, or
56+
# no-op if the base branch is already up-to-date.
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
59+
with:
60+
author: Node.js GitHub Bot <[email protected]>
61+
body: This is an automated update of ${{ matrix.id }} to ${{ env.NEW_VERSION }}.
62+
branch: actions/update-v8-${{ matrix.id }} # Custom branch *just* for this Action.
63+
commit-message: ${{ env.COMMIT_MSG }}
64+
labels: ${{ matrix.label }}
65+
title: '${{ matrix.subsystem }}: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}'
66+
update-pull-request-title-and-body: true

tools/dep_updaters/update-v8-minor.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update v8 minor update
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
7+
cd "$BASE_DIR"
8+
9+
IS_UP_TO_DATE=$(git node v8 minor | grep "V8 is up-to-date")
10+
11+
if [ -n "$IS_UP_TO_DATE" ]; then
12+
echo "Skipped because V8 is on the latest version."
13+
exit 0
14+
fi
15+
16+
DEPS_DIR="$BASE_DIR/deps"
17+
18+
CURRENT_MAJOR_VERSION=$(grep "#define V8_MAJOR_VERSION" "$DEPS_DIR/v8/include/v8-version.h" | cut -d ' ' -f3)
19+
CURRENT_MINOR_VERSION=$(grep "#define V8_MINOR_VERSION" "$DEPS_DIR/v8/include/v8-version.h" | cut -d ' ' -f3)
20+
CURRENT_BUILD_VERSION=$(grep "#define V8_BUILD_NUMBER" "$DEPS_DIR/v8/include/v8-version.h" | cut -d ' ' -f3)
21+
CURRENT_PATCH_VERSION=$(grep "#define V8_PATCH_LEVEL" "$DEPS_DIR/v8/include/v8-version.h" | cut -d ' ' -f3)
22+
23+
NEW_VERSION="$CURRENT_MAJOR_VERSION.$CURRENT_MINOR_VERSION.$CURRENT_BUILD_VERSION.$CURRENT_PATCH_VERSION"
24+
25+
echo "All done!"
26+
echo ""
27+
echo "Please git add v8, commit the new version:"
28+
echo ""
29+
echo "$ git add -A deps/v8"
30+
echo "$ git commit -m \"deps: update v8 to $NEW_VERSION\""
31+
echo ""
32+
33+
# The last line of the script should always print the new version,
34+
# as we need to add it to $GITHUB_ENV variable.
35+
echo "NEW_VERSION=$NEW_VERSION"

tools/dep_updaters/update-v8-patch.sh

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)