resolveVersionKeyIncrement = (
  mergedPullRequests,
  config,
  isPreRelease
) => {
  const priorityMap = {
    patch: 1,
    minor: 2,
    major: 3,
  }

  const labelToKeyMap = Object.fromEntries(
    Object.keys(priorityMap)
      .flatMap((key) => [
        config['version-resolver'][key].labels.map((label) => [label, key]),
      ])
      .flat()
  )

  core.debug('labelToKeyMap: ' + JSON.stringify(labelToKeyMap))

  const keys = mergedPullRequests
    .filter(getFilterExcludedPullRequests(config['exclude-labels']))
    .filter(getFilterIncludedPullRequests(config['include-labels']))
    .flatMap((pr) => pr.labels.nodes.map((node) => labelToKeyMap[node.name]))
    .filter(Boolean)

  core.debug('keys: ' + JSON.stringify(keys))

  const keyPriorities = keys.map((key) => priorityMap[key])
  const priority = Math.max(...keyPriorities)
  const versionKey = Object.keys(priorityMap).find(
    (key) => priorityMap[key] === priority
  )

  core.debug('versionKey: ' + versionKey)

  const versionKeyIncrement = versionKey || config['version-resolver'].default

  const shouldIncrementAsPrerelease =
    isPreRelease && config['prerelease-identifier']

  if (!shouldIncrementAsPrerelease) {
    return versionKeyIncrement
  }

  return `pre${versionKeyIncrement}`
}
replaces all uppercase dollar templates with their string representation from object
if replacement is undefined in object the dollar template string is left untouched