Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compare version #32

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,28 @@ runs:
- name: 'Check input parameter'
shell: 'bash'
run: |
if [[ "${{ inputs.version }}" < "v0.64.0" ]]; then
echo "Error: runn version ${{ inputs.version }} is not supported. Please use v0.64.0 or higher."
exit 1
fi
# vx.y.z -> x.y.z
input_version=$(echo "${{ inputs.version }}" | sed 's/^v//')
compatible_version=$(echo "v0.64.0" | sed 's/^v//')

# x.y.z -> [x, y, z]
IFS='.' read -r -a splitted_input_version <<< "$input_version"
IFS='.' read -r -a splitted_compatible_version <<< "$compatible_version"

for i in {0..2}; do
# check if number
if [[ ! ${splitted_input_version[i]} =~ ^[0-9]+$ ]]; then
echo "Error: $input_version is invalid version."
exit 1
fi

# compare version
if ((10#${splitted_input_version[i]} < 10#${splitted_compatible_version[i]})); then
echo "Error: runn version $input_version is not supported. Please use $compatible_version or higher."
exit 1
fi
done

if [[ ! "${{ inputs.command }}" =~ ^(run|list|loadt)$ ]]; then
echo "Error: Invalid command ${{ inputs.command }} is not supported. Please specify run or list or loadt."
exit 1
Expand Down