Skip to content

Commit e3f9a77

Browse files
legendecascclauss
andauthored
chore: add gyp-next updater (#3105)
* chore: add gyp-next updater Co-authored-by: Christian Clauss <[email protected]>
1 parent 44cea2e commit e3f9a77

File tree

3 files changed

+62
-5
lines changed

3 files changed

+62
-5
lines changed

.github/workflows/release-please.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ jobs:
99
release-please:
1010
outputs:
1111
release_created: ${{ steps.release.outputs.release_created }}
12-
permissions:
13-
contents: write # to create release commit (googleapis/release-please-action)
14-
pull-requests: write # to create release PR (googleapis/release-please-action)
1512
runs-on: ubuntu-latest
1613
steps:
1714
- uses: googleapis/release-please-action@v4
1815
id: release
16+
with:
17+
token: ${{ secrets.GH_USER_TOKEN }}
1918
# Standard Conventional Commits: `feat` and `fix`
2019
# node-gyp subdirectories: `bin`, `gyp`, `lib`, `src`, `test`
2120
# node-gyp subcommands: `build`, `clean`, `configure`, `install`, `list`, `rebuild`, `remove`

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
24+
- uses: actions/github-script@v7
25+
id: get-gyp-next-version
26+
with:
27+
script: |
28+
const result = await github.rest.repos.getLatestRelease({
29+
owner: 'nodejs',
30+
repo: 'gyp-next',
31+
});
32+
return result.data.tag_name
33+
result-encoding: string
34+
35+
- name: Update gyp-next
36+
run: |
37+
python update-gyp.py --no-commit ${{ steps.get-gyp-next-version.outputs.result }}
38+
39+
- name: Open or update PR for the gyp-next update
40+
uses: gr2m/create-or-update-pull-request-action@v1
41+
with:
42+
branch: actions/update-gyp-next
43+
author: Node.js GitHub Bot <[email protected]>
44+
title: 'feat: update gyp-next to ${{ steps.get-gyp-next-version.outputs.result }}'
45+
commit-message: 'feat: update gyp-next to ${{ steps.get-gyp-next-version.outputs.result }}'
46+
update-pull-request-title-and-body: true
47+
body: >
48+
This is an automated update of the gyp-next to
49+
https://github.com/nodejs/gyp-next/releases/tag/${{ steps.get-gyp-next-version.outputs.result }}.
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}

update-gyp.py

Lines changed: 9 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,8 @@ 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([
70+
"git", "commit", "-m", f"feat(gyp): update gyp to {args.tag}"
71+
])

0 commit comments

Comments
 (0)