From d347632046f50403d56580d0393c1bcc4418cb11 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 30 Jun 2025 15:01:09 -0700 Subject: [PATCH] build: write abi version to published npm package (#47598) --- script/release/bin/publish-to-npm.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/script/release/bin/publish-to-npm.ts b/script/release/bin/publish-to-npm.ts index 484bece93c61..43ae273552d1 100644 --- a/script/release/bin/publish-to-npm.ts +++ b/script/release/bin/publish-to-npm.ts @@ -136,6 +136,20 @@ new Promise((resolve, reject) => { return release; }) + .then(async (release) => { + const gnArgs = await fs.promises.readFile(path.resolve(ELECTRON_DIR, 'build/args/all.gn'), 'utf8'); + + const abiVersionLine = gnArgs.split('\n').find((line) => line.startsWith('node_module_version = ')); + const abiVersion = abiVersionLine ? abiVersionLine.split('=')[1].trim() : null; + if (!abiVersion) { + throw new Error('Could not find node_module_version in GN args'); + } + + const abiVersionFile = path.join(tempDir, 'abi_version'); + await fs.promises.writeFile(abiVersionFile, abiVersion); + + return release; + }) .then(async (release) => { const currentBranch = await getCurrentBranch();