name: version-increment
description: "Increment a semantic version 2.0."
inputs:
  incrementMode:
    description: "The mode to increment by. Options: 'default', 'major', 'minor', 'patch', 'revision'"
    required: true
    default: default
  gitShaMetadata:
    description: "Whether or not to update the git sha in the metadata."
    required: false
    default: "false"
  major:
    description: "The latest major version of the package."
    required: false
  minor:
    description: "The latest minor version of the package."
    required: false
  patch:
    description: "The latest patch version of the package."
    required: false
  revision:
    description: "The latest patch revision version of the package. The suffix treated as a number seperated by a '.'"
    required: false
  suffix:
    description: "The suffix of the package."
    required: false
  metadata:
    description: "The metadata of the package."
    required: false
outputs:
  nextVersion:
    description: "The next version of the package."
    value: ${{ steps.parse.outputs.nextVersion }}
  nextMajor:
    description: "The next major version of the package."
    value: ${{ steps.parse.outputs.nextMajor }}
  nextMinor:
    description: "The next minor version of the package."
    value: ${{ steps.parse.outputs.nextMinor }}
  nextPatch:
    description: "The next patch version of the package."
    value: ${{ steps.parse.outputs.nextPatch }}
  nextRevision:
    description: "The next patch revision version of the package."
    value: ${{ steps.parse.outputs.nextRevision }}
  nextSuffix:
    description: "The next version of suffix of the package."
    value: ${{ steps.parse.outputs.nextSuffix }}
  nextMetadata:
    description: "The next version of metadata of the package."
    value: ${{ steps.parse.outputs.nextMetadata }}
runs:
  using: "composite"
  steps:
  - name: "Get next version."
    id: parse
    run: |
      bash ${{ github.action_path }}/increment_version.sh "${{ inputs.major }}" "${{ inputs.minor }}" "${{ inputs.patch }}" "${{ inputs.revision }}" "${{ inputs.suffix }}" "${{ inputs.metadata }}" "${{ inputs.incrementMode }}" "${{ inputs.gitShaMetadata }}"
    shell: bash