diff --git a/.github/workflows/update-gyp-next.yml b/.github/workflows/update-gyp-next.yml new file mode 100644 index 0000000000..46b758fc53 --- /dev/null +++ b/.github/workflows/update-gyp-next.yml @@ -0,0 +1,52 @@ +name: Update gyp-next + +on: + schedule: + # Run once a week at 12:00 AM UTC on Sunday. + - cron: 0 0 * * * + workflow_dispatch: + +permissions: + contents: read + +env: + NODE_VERSION: lts/* + +jobs: + update-gyp-next: + # if: github.repository == 'nodejs/node' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - uses: actions/github-script@v7 + id: get-gyp-next-version + with: + script: | + const result = await github.rest.repos.getLatestRelease({ + owner: 'nodejs', + repo: 'gyp-next', + }); + return result.data.tag_name + result-encoding: string + + - name: Update gyp-next + run: | + python update-gyp.py --no-commit ${{ steps.get-gyp-next-version.outputs.result }} + + - name: Open or update PR for the gyp-next update + uses: gr2m/create-or-update-pull-request-action@v1 + with: + branch: actions/update-gyp-next + author: Node.js GitHub Bot + title: 'feat: update gyp-next to ${{ steps.get-gyp-next-version.outputs.result }}' + commit-message: 'feat: update gyp-next to ${{ steps.get-gyp-next-version.outputs.result }}' + update-pull-request-title-and-body: true + body: > + This is an automated update of the gyp-next to + https://github.com/nodejs/gyp-next/releases/tag/${{ steps.get-gyp-next-version.outputs.result }}. + env: + GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} diff --git a/update-gyp.py b/update-gyp.py index 70e2d10028..2a4db2079d 100755 --- a/update-gyp.py +++ b/update-gyp.py @@ -13,6 +13,10 @@ CHECKOUT_GYP_PATH = os.path.join(CHECKOUT_PATH, "gyp") parser = argparse.ArgumentParser() +parser.add_argument("--no-commit", + action="store_true", + dest="no_commit", + help="do not run git-commit") parser.add_argument("tag", help="gyp tag to update to") args = parser.parse_args() @@ -60,5 +64,6 @@ def safe_extract(tar, path=".", members=None, *, numeric_owner=False): os.path.join(unzip_target, os.listdir(unzip_target)[0]), CHECKOUT_GYP_PATH ) -subprocess.check_output(["git", "add", "gyp"], cwd=CHECKOUT_PATH) -subprocess.check_output(["git", "commit", "-m", "feat(gyp): update gyp to " + args.tag]) +if not args.no_commit: + subprocess.check_output(["git", "add", "gyp"], cwd=CHECKOUT_PATH) + subprocess.check_output(["git", "commit", "-m", "feat(gyp): update gyp to " + args.tag])