code: def main(args):
      # current version
      last_tag = (
          subprocess.run(
              ["git", "describe", "--abbrev=0", "--tags"],
              stdout=subprocess.PIPE,
          )
          .stdout.decode("utf-8")
          .strip()
      )
      # last_tag="4.2.3-rc1"
      # last_tag="3.2.1"
      tags = re.split("\.|-rc", last_tag)
      new_tags = [int(i) for i in tags]
  
      # parse args
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "-y",
          default=False,
          dest="confirmed",
          action="store_true",
          help="In interactive mode, for user to confirm. Could be used in script",
      )
      parser.add_argument(
          "type",
          choices=["major", "minor", "patch", "rc", "stable"],
          help="Release types",
      )
      args = parser.parse_args(args)
  
      # check eligibility of arg
      if args.type in ["major", "minor", "patch"]:
          if len(tags) == 4:
              exit(
                  'Current type "%s" is not allowed in pre release(version %s)'
                  % (args.type, last_tag)
              )
      if args.type in ["stable", "rc"]:
          if len(tags) == 3:
              exit(
                  'Current type "%s" is not allowed in stable release(version %s)'
                  % (args.type, last_tag)
              )
  
      # new version
      if args.type == "major":
          new_tags[0] += 1
          new_tags[1] = 0
          new_tags[2] = 0
          new_tags.append(0)
      elif args.type == "minor":
          new_tags[1] += 1
          new_tags[2] = 0
          new_tags.append(0)
      elif args.type == "patch":
          new_tags[2] += 1
          new_tags.append(0)
      elif args.type == "stable":
          new_tags.pop(-1)
      elif args.type == "rc":
          new_tags[3] += 1
  
      # ask for confirmation
      print(
          "Please confirm bumping version from %s to %s"
          % (last_tag, tag_string(new_tags))
      )
      ans = "y" if args.confirmed else ""
      while ans not in ["y", "n"]:
          ans = input("OK to continue [Y/N]? ").lower()
      if ans == "y":
          print(
              "Confirmed bumping version from %s to %s"
              % (last_tag, tag_string(new_tags))
          )
      else:
          exit("Aborted")
  
      # do the rest of the work
      # git tag -a $NEW_VERSION -m "Version: $NEW_VERSION"
      print(
          subprocess.run(
              [
                  "git",
                  "tag",
                  "-a",
                  tag_string(new_tags),
                  "-m",
                  "new version",
              ],
              stdout=subprocess.PIPE,
          ).stdout
      )
      # git push dcslin -f --tags
      # print( subprocess.run(['git', 'push', 'dcslin', '-f', '--tags'], stdout=subprocess.PIPE).stdout) # test
      print(
          subprocess.run(
              ["git", "push", "--tags"], stdout=subprocess.PIPE
          ).stdout
      )
      print("Done. Pushed to remote")
  
imports: import subprocess
  import re
  import argparse
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: main(args) without return types