Skip to content

Commit

Permalink
Try bumping
Browse files Browse the repository at this point in the history
  • Loading branch information
nutjob4life committed Mar 14, 2024
1 parent ee739bc commit d279fb1
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/pds/roundup/_nodejs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .errors import RoundupError, InvokedProcessError
from .step import Step, StepName, NullStep, RequirementsStep, DocPublicationStep, ChangeLogStep as BaseChangeLogStep
from .util import git_config, invoke, invokeGIT, TAG_RE, add_version_label_to_open_bugs, commit, delete_tags
import shutil, logging, os, json, re, datetime
import shutil, logging, os, json, re

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -36,6 +36,9 @@ def __init__(self, cwd, environ, args):
class _NodeJSStep(Step):
'''A Node.js-specific step.'''

# A version regular expression adhereing to npm's strict semver policy
semver_re = re.compile(r'^(\d+)\.(\d+)\.(\d+)')

def read_package_metadata(self):
'''Read the package.json file and yield its contents as a dict.'''
_logger.debug('Getting package metdadata from package.json')
Expand Down Expand Up @@ -231,10 +234,20 @@ def execute(self):
argv = ['npm', 'publish', '--verbose', '--access', 'public']
else:
# In NASA-PDS/devops#69 @jordanpadams pefers "beta" to "unstable". This was
# corroborated in our stand up meeting on 2024-03-05. Further, we need a
# timestamp on unstable releases; Java and Python release do this automatically.
ts = datetime.datetime.utcnow().strftime('%Y%m%d%H%M%S')
argv = ['npm', 'publish', '--verbose', '--access', 'public', '--tag', f'beta-{ts}']
# corroborated in our stand up meeting on 2024-03-05.
#
# Also, apparently there's no way to re-release an unstable package to npm.
# We have to bump the version number.

metadata = self.read_package_metadata()
match = TAG_RE.match(metadata['version'])
if not match:
raise RoundupError(f'The version number {metadata["version"]} in package.json is malformed')

major, minor, micro = int(match.group(1)), int(match.group(2)), int(match.group(3)) + 1
self.write_version_number(f'{major}.{minor}.{micro}')
argv = ['npm', 'publish', '--verbose', '--access', 'public']
commit('package.json', f'Committing bumped version № {major}.{minor}.{micro} for unstable assembly')
invoke(argv)
except InvokedProcessError:
# For unstalbe releases, we ignore this
Expand Down

0 comments on commit d279fb1

Please sign in to comment.