mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
01e4ccbc54
This adds a new Github Action that semantically compares two versions, like 2.1.1 and 2.3.0 giving information about whether or the version is "higher" or "lower" than another version. The action exposes an output called `result` which will match the return type of the PHP [version_compare](https://www.php.net/manual/en/function.version-compare.php) function. Currently, this action compares `version` against `compare_against` and returns: - `-1` - if `version` is lower than `compare_against` - `0` - if `version` is equal to `compare_against` - `1` - if `version` is greater than `compare_against` Co-authored-by: Vitaliy Golomoziy <vitaliy.golomoziy@gmail.com>
30 lines
837 B
YAML
30 lines
837 B
YAML
name: "Semver Compare"
|
|
author: "Graycore"
|
|
description: "A Github Action that compares two versions, semantically"
|
|
|
|
inputs:
|
|
version:
|
|
required: true
|
|
description: "Original version"
|
|
|
|
compare_against:
|
|
required: true
|
|
description: "The version to compare against"
|
|
|
|
outputs:
|
|
result: # id of output
|
|
description: "The result of comparison. By default, this returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower."
|
|
value: ${{ steps.semver-compare.outputs.result }}
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Semantically compare two versions
|
|
run: php -r "echo 'result=' . version_compare('${{ inputs.version }}', '${{ inputs.compare_against }}');" >> $GITHUB_OUTPUT
|
|
shell: bash
|
|
id: semver-compare
|
|
|
|
branding:
|
|
icon: "code"
|
|
color: "green"
|