From f2145ae99b99a5cbd204024f4b32487b47cd374e Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 31 Aug 2023 10:32:40 +0200 Subject: [PATCH] renamed version checker script [skip ci] --- automation_tools/version_checker.sh | 62 +++++++++++++++++++++++++++ automation_tools/version_extractor.sh | 31 -------------- 2 files changed, 62 insertions(+), 31 deletions(-) create mode 100755 automation_tools/version_checker.sh delete mode 100755 automation_tools/version_extractor.sh diff --git a/automation_tools/version_checker.sh b/automation_tools/version_checker.sh new file mode 100755 index 00000000..a16e163f --- /dev/null +++ b/automation_tools/version_checker.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# This script is used to check that the versions are correct and topping the pipeline if something is wrong. +# This is designed to be run on main pipeline to check that everything is in order before building RetroDECK. + +# Set the file paths +appdata="net.retrodeck.retrodeck.appdata.xml" +manifest="net.retrodeck.retrodeck.yml" +manifest_content=$(cat "$manifest") + +compare_versions() { + local manifest_version_cleaned=$(echo "$1" | sed 's/[a-zA-Z]//g') + local appdata_version_cleaned=$(echo "$2" | sed 's/[a-zA-Z]//g') + + if [[ "$manifest_version_cleaned" == "$appdata_version_cleaned" ]]; then + return 0 # Versions are equal + fi + + local IFS=. + local manifest_parts=($manifest_version_cleaned) + local appdata_parts=($appdata_version_cleaned) + + for ((i=0; i<${#manifest_parts[@]}; i++)); do + if ((manifest_parts[i] > appdata_parts[i])); then + return 1 # Manifest version is greater + elif ((manifest_parts[i] < appdata_parts[i])); then + return 2 # Appdata version is greater + fi + done + + return 0 # Versions are equal +} + +# Getting latest RetroDECK release info +LATEST_RELEASE=$(curl -s "https://api.github.com/repos/XargonWan/RetroDECK/releases/latest") +# Extracting tag name from the latest release +repo_version=$(echo "$LATEST_RELEASE" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +# Printing results +echo -e "Online repository:\t$repo_version" + +# Extract the version from the net.retrodeck.retrodeck.appdata.xml file +appdata_version=$(grep -oPm1 "(?<=