Skip to content

Commit 954a5c8

Browse files
committed
chore: add gyp-next updater
1 parent 0e6b6f8 commit 954a5c8

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

.github/workflows/update-gyp-next.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Update gyp-next
2+
3+
on:
4+
schedule:
5+
# Run once a week at 12:00 AM UTC on Sunday.
6+
- cron: 0 0 * * *
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
env:
13+
NODE_VERSION: lts/*
14+
15+
jobs:
16+
update-gyp-next:
17+
# if: github.repository == 'nodejs/node' || github.event_name == 'workflow_dispatch'
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false
24+
25+
- uses: actions/github-script@v7
26+
id: get-gyp-next-version
27+
with:
28+
script: |
29+
const result = await github.rest.repos.getLatestRelease({
30+
owner: 'nodejs',
31+
repo: 'gyp-next',
32+
});
33+
return result.data.tag_name
34+
result-encoding: string
35+
36+
- name: Update gyp-next
37+
run: |
38+
python update-gyp.py --no-commit ${{ steps.get-gyp-next-version.outputs.result }}
39+
40+
- name: Open or update PR for the gyp-next update
41+
uses: gr2m/create-or-update-pull-request-action@v1
42+
with:
43+
branch: actions/update-gyp-next
44+
author: Node.js GitHub Bot <[email protected]>
45+
title: 'feat: update gyp-next to ${{ steps.get-gyp-next-version.outputs.result }}'
46+
commit-message: 'feat: update gyp-next to ${{ steps.get-gyp-next-version.outputs.result }}'
47+
update-pull-request-title-and-body: true
48+
body: >
49+
This is an automated update of the gyp-next to
50+
https://github.com/nodejs/gyp-next/releases/tag/${{ steps.get-gyp-next-version.outputs.result }}.
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}

update-gyp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
CHECKOUT_GYP_PATH = os.path.join(CHECKOUT_PATH, "gyp")
1414

1515
parser = argparse.ArgumentParser()
16+
parser.add_argument("--no-commit",
17+
action="store_true",
18+
dest="no_commit",
19+
help="do not run git-commit")
1620
parser.add_argument("tag", help="gyp tag to update to")
1721
args = parser.parse_args()
1822

@@ -60,5 +64,6 @@ def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
6064
os.path.join(unzip_target, os.listdir(unzip_target)[0]), CHECKOUT_GYP_PATH
6165
)
6266

63-
subprocess.check_output(["git", "add", "gyp"], cwd=CHECKOUT_PATH)
64-
subprocess.check_output(["git", "commit", "-m", "feat(gyp): update gyp to " + args.tag])
67+
if not args.no_commit:
68+
subprocess.check_output(["git", "add", "gyp"], cwd=CHECKOUT_PATH)
69+
subprocess.check_output(["git", "commit", "-m", "feat(gyp): update gyp to " + args.tag])

0 commit comments

Comments
 (0)