Files
node/tools/getnodeversion.py
Rafael Gonzaga 7abbd56cfd doc: document the alpha release process
Document how to prepare, version, tag and promote the Alpha releases
introduced by the new release schedule, starting with Node.js 27, and
how the first Alpha and semver-major releases are prepared with
git node release.

Refs: https://github.com/nodejs/Release/issues/1187
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/66796
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-10-26 16:32:08 +00:00

44 lines
1.4 KiB
Python

from __future__ import print_function
import os
import sys
def get_major_minor_patch(text):
for line in text.splitlines():
if line.startswith('#define NODE_MAJOR_VERSION'):
major = line.split()[2]
elif line.startswith('#define NODE_MINOR_VERSION'):
minor = line.split()[2]
elif line.startswith('#define NODE_PATCH_VERSION'):
patch = line.split()[2]
return major, minor, patch
def get_alpha_tag(text):
is_release = False
alpha = {}
for line in text.splitlines():
if line.startswith('#define NODE_VERSION_IS_RELEASE'):
is_release = line.split()[2] == '1'
elif line.startswith('#define NODE_ALPHA_MAJOR_VERSION'):
alpha['major'] = line.split()[2]
elif line.startswith('#define NODE_ALPHA_MINOR_VERSION'):
alpha['minor'] = line.split()[2]
elif line.startswith('#define NODE_ALPHA_PATCH_VERSION'):
alpha['patch'] = line.split()[2]
if not is_release or 'major' not in alpha:
return ''
return '-alpha.' + '.'.join((alpha['major'], alpha['minor'], alpha['patch']))
node_version_h = os.path.join(os.path.dirname(__file__),
'..',
'src',
'node_version.h')
with open(node_version_h) as in_file:
text = in_file.read()
version = '.'.join(get_major_minor_patch(text))
if '--full' in sys.argv[1:]:
version += get_alpha_tag(text)
print(version)