2023-08-31 09:07:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2023-09-26 07:08:29 +00:00
|
|
|
# This script is intended to gather version information from various sources:
|
|
|
|
|
# RetroDECK repository
|
2025-01-30 04:36:33 +00:00
|
|
|
# Metainfo.xml file
|
2023-09-26 07:08:29 +00:00
|
|
|
# It consists of three functions, each responsible for retrieving a specific version-related data.
|
|
|
|
|
|
2025-01-30 04:36:33 +00:00
|
|
|
metainfo="net.retrodeck.retrodeck.metainfo.xml"
|
2023-08-31 10:40:38 +00:00
|
|
|
|
2023-08-31 09:07:00 +00:00
|
|
|
fetch_repo_version(){
|
|
|
|
|
# Getting latest RetroDECK release info
|
2024-08-01 15:57:19 +00:00
|
|
|
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/RetroDECK/RetroDECK/releases/latest")
|
2023-08-31 09:07:00 +00:00
|
|
|
# Extracting tag name from the latest release
|
|
|
|
|
repo_version=$(echo "$LATEST_RELEASE" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
|
|
|
|
# Printing results
|
|
|
|
|
echo "$repo_version"
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-30 04:36:33 +00:00
|
|
|
fetch_metainfo_version(){
|
2025-03-29 00:59:02 +00:00
|
|
|
# Extract the version number from the metainfo XML file
|
|
|
|
|
VERSION=$(xmlstarlet sel -t -v "/component/releases/release[1]/@version" net.retrodeck.retrodeck.metainfo.xml)
|
|
|
|
|
echo "$VERSION"
|
2023-08-31 09:07:00 +00:00
|
|
|
}
|
2024-07-18 04:25:52 +00:00
|
|
|
|
2025-03-29 01:17:49 +00:00
|
|
|
# TODO: cooker_build_id logic can be moved here
|
|
|
|
|
|
|
|
|
|
fetch_actual_version(){
|
|
|
|
|
# If the current Git branch is not 'main', append 'cooker-' to the version number
|
|
|
|
|
if [[ "${GITHUB_REF_NAME}" != "main" ]]; then
|
|
|
|
|
VERSION="cooker-$(cat ./version)-$(cat buildid)"
|
|
|
|
|
else # Otherwise, if we're on main, use the version number as is
|
|
|
|
|
VERSION=$(cat ./version)
|
|
|
|
|
fi
|
|
|
|
|
echo "$VERSION"
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-18 04:25:52 +00:00
|
|
|
echo "Version extractor functions loaded"
|