Files
common/utils/version-increment-branch/action.yaml
2025-07-01 14:00:26 -07:00

63 lines
2.3 KiB
YAML

name: version-increment-branch
description: "Get the latest and next version of a package from a NuGet repository based on the current branch and merge target."
inputs:
version:
description: "The version to increment."
required: false
outputs:
nextVersion:
description: "The next version of the package, based on the current branch and merge target."
value: ${{ steps.increment.outputs.nextVersion }}
baseVersion:
description: "Base of the branch-defined version."
value: ${{ steps.branch.outputs.baseVersion }}
majorMinorPatchVersion:
description: "Major.Minor.Patch of the latest version."
value: ${{ steps.branch.outputs.majorMinorPatchVersion }}
runs:
using: "composite"
steps:
- name: "Get latest non-pre-release NuGet package version."
id: parse
uses: act/common/utils/version-parse@master
with:
version: ${{ inputs.version }}
- name: "Build the next version with the given repository information."
id: branch
run: |
NAME="Version Increment Branch"
echo "::group::$NAME - Inputs"
echo "${{ toJSON(inputs) }}"
echo "::endgroup::"
EVENT_NAME="${{ github.event_name }}"
HEAD="${{ github.head_ref || github.ref_name }}"
BASE="${{ github.base_ref || github.ref_name }}"
PR_NUMBER="${{ github.event.number || '-1' }}"
MAJOR="${{ steps.parse.outputs.major || '0' }}"
MINOR="${{ steps.parse.outputs.minor || '0' }}"
PATCH="${{ steps.parse.outputs.patch || '0' }}"
LAST_MMP_VERSION="$MAJOR.$MINOR.$PATCH"
REVISION="${{ steps.parse.outputs.revision || '0' }}"
bash ${{ github.action_path }}/get_next_version.sh "$EVENT_NAME" "$HEAD" "$BASE" "$PR_NUMBER" "$LAST_MMP_VERSION" "$REVISION"
shell: bash
- name: "Parse the version to increment."
id: parseNext
uses: act/common/utils/version-parse@master
with:
version: ${{ steps.branch.outputs.currentVersion }}
- name: "Get next version."
id: increment
uses: act/common/utils/version-increment@master
with:
incrementMode: revision
major: ${{ steps.parseNext.outputs.major }}
minor: ${{ steps.parseNext.outputs.minor }}
patch: ${{ steps.parseNext.outputs.patch }}
revision: ${{ steps.parseNext.outputs.revision }}
suffix: ${{ steps.parseNext.outputs.suffix }}
metadata: ${{ steps.parseNext.outputs.metadata }}