From 8be9782ff70e85965b39adb2073ad6a063534014 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Sat, 29 Mar 2025 09:59:02 +0900 Subject: [PATCH] feat/auto version (#1072) * MANIFEST: Update version initialization to dynamically extract version from metainfo XML * BUILD: now version is automated and taken from the metainfo --- .gitignore | 1 + automation_tools/cooker_build_id.sh | 8 ++- automation_tools/main_version_checker.sh | 63 ------------------------ automation_tools/version_extractor.sh | 17 ++----- net.retrodeck.retrodeck.yml | 29 ++++++----- 5 files changed, 29 insertions(+), 89 deletions(-) delete mode 100755 automation_tools/main_version_checker.sh diff --git a/.gitignore b/.gitignore index 0ec7f72e..9c0c447e 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ placeholders.cache RetroDECK*Artifact.tar.gz ./gits flathub.json +./version # Components artifacts # ############################ diff --git a/automation_tools/cooker_build_id.sh b/automation_tools/cooker_build_id.sh index b1175e56..5f2e0315 100755 --- a/automation_tools/cooker_build_id.sh +++ b/automation_tools/cooker_build_id.sh @@ -7,4 +7,10 @@ capitalized_word2="$(tr '[:lower:]' '[:upper:]' <<< ${word2:0:1})${word2:1}" result=$capitalized_word1$capitalized_word2 echo $result > ${GITHUB_WORKSPACE}/buildid echo "BUILD_ID=$result" >> $GITHUB_ENV -echo "VersionID is $result" \ No newline at end of file +echo "VersionID is $result" + +source automation_tools/version_extractor.sh +VERSION=$(fetch_metainfo_version) +echo "$VERSION" > ${GITHUB_WORKSPACE}/version +echo "VERSION=$VERSION" >> $GITHUB_ENV +echo "Version is $VERSION" \ No newline at end of file diff --git a/automation_tools/main_version_checker.sh b/automation_tools/main_version_checker.sh deleted file mode 100755 index 5c814a03..00000000 --- a/automation_tools/main_version_checker.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# This script is used to check that the versions are correct and stopping the pipeline if something is wrong. -# This is designed to be run on the main pipeline to check that everything is in order before building RetroDECK. - -source automation_tools/version_extractor.sh - -# Set the file paths -metainfo="net.retrodeck.retrodeck.metainfo.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 metainfo_version_cleaned=$(echo "$2" | sed 's/[a-zA-Z]//g') - - if [[ "$manifest_version_cleaned" == "$metainfo_version_cleaned" ]]; then - return 0 # Versions are equal - fi - - local IFS=. - local manifest_parts=($manifest_version_cleaned) - local metainfo_parts=($metainfo_version_cleaned) - - for ((i=0; i<${#manifest_parts[@]}; i++)); do - if ((manifest_parts[i] > metainfo_parts[i])); then - return 1 # Manifest version is greater - elif ((manifest_parts[i] < metainfo_parts[i])); then - return 2 # Metainfo version is greater - fi - done - - return 0 # Versions are equal -} - -repo_version=$(fetch_repo_version) -echo -e "Online repository:\t$repo_version" - -manifest_version=$(fetch_manifest_version) -echo -e "Manifest:\t\t$manifest_version" - -metainfo_version=$(fetch_metainfo_version) -echo -e "Metainfo:\t\t$metainfo_version" - -# Additional checks -if [[ "$manifest_version" == "main" || "$manifest_version" == "THISBRANCH" || "$manifest_version" == *"cooker"* ]]; then - echo "Manifest version cannot be 'main', 'THISBRANCH', or contain 'cooker'. Please fix it." - exit 1 -fi - -if [[ "$metainfo_version" != "$manifest_version" ]]; then - echo "Metainfo version is not equal to manifest version. Please fix it." - exit 1 -fi - -compare_versions "$repo_version" "$manifest_version" -result=$? - -if [ "$result" -eq 1 ]; then - echo "Repository version is less than manifest version. Please fix it." - exit 1 -fi - -echo "All checks passed. Well done!" \ No newline at end of file diff --git a/automation_tools/version_extractor.sh b/automation_tools/version_extractor.sh index e9cc1cef..25ba4744 100755 --- a/automation_tools/version_extractor.sh +++ b/automation_tools/version_extractor.sh @@ -3,12 +3,9 @@ # This script is intended to gather version information from various sources: # RetroDECK repository # Metainfo.xml file -# Manifest YAML file # It consists of three functions, each responsible for retrieving a specific version-related data. metainfo="net.retrodeck.retrodeck.metainfo.xml" -manifest="net.retrodeck.retrodeck.yml" -manifest_content=$(cat "$manifest") fetch_repo_version(){ # Getting latest RetroDECK release info @@ -20,17 +17,9 @@ fetch_repo_version(){ } fetch_metainfo_version(){ - # Extract the version from the net.retrodeck.retrodeck.metainfo.xml file - metainfo_version=$(grep -oPm1 "(?<=> ${FLATPAK_DEST}/retrodeck/version + + # Display the contents of the version file cat ${FLATPAK_DEST}/retrodeck/version + + # Print the version number to the console echo "Version is $VERSION" # LIBMAN INSTALLATION