From 1cdf81aab0533aee3d449fccf76a98eb47576570 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Sat, 29 Mar 2025 10:17:49 +0900 Subject: [PATCH] refactor: update version extraction logic to include build ID and streamline version fetching --- .github/workflows/build_retrodeck.yml | 14 +++++++------- automation_tools/version_extractor.sh | 12 ++++++++++++ net.retrodeck.retrodeck.yml | 8 ++------ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build_retrodeck.yml b/.github/workflows/build_retrodeck.yml index b95b5335..21549f45 100644 --- a/.github/workflows/build_retrodeck.yml +++ b/.github/workflows/build_retrodeck.yml @@ -106,20 +106,20 @@ jobs: - name: Generate Version Tag id: version-tag run: | - # Source the version extractor script and fetch the manifest version + # Source the version extractor script and fetch the actual version, including the build ID source automation_tools/version_extractor.sh - MANIFEST_VERSION="$(fetch_manifest_version)" + VERSION="$(fetch_actual_version)" - # Ensure the manifest version was successfully extracted - if [[ -z "$MANIFEST_VERSION" ]]; then - echo "[ERROR] Failed to extract the manifest version." + # Ensure the actual version was successfully extracted + if [[ -z "$VERSION" ]]; then + echo "[ERROR] Failed to extract the actual version." exit 1 fi # Determine the tag based on the GitHub event context if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then # Main branch tag - TAG="$MANIFEST_VERSION" + TAG="$VERSION" MAKE_LATEST=true elif [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "pull_request_target" ]]; then # Pull request tag, sanitize the source branch @@ -128,7 +128,7 @@ jobs: MAKE_LATEST=false else # Other branches (cooker branches) - TAG="$MANIFEST_VERSION-${{ env.BUILD_ID }}" + TAG="$VERSION-${{ env.BUILD_ID }}" MAKE_LATEST=true fi diff --git a/automation_tools/version_extractor.sh b/automation_tools/version_extractor.sh index 25ba4744..4f7711c5 100755 --- a/automation_tools/version_extractor.sh +++ b/automation_tools/version_extractor.sh @@ -22,4 +22,16 @@ fetch_metainfo_version(){ echo "$VERSION" } +# 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" +} + echo "Version extractor functions loaded" \ No newline at end of file diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index fca784db..1a457d87 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -83,12 +83,8 @@ modules: - | # VERSION INITIALIZATION - # 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 + source "automation_tools/version_extractor.sh" + VERSION=$(fetch_actual_version) # Check out the current Git branch git checkout ${GITHUB_REF_NAME}