ChewKeanHo / AutomataCI

An open-source, redistributable, template-guided, and semi-autonomous CI infrastructure readily available your next project.
Apache License 2.0
21 stars 1 forks source link

Package CI job's `TARGET_OS` and `TARGET_ARCH` can pick up extensions (e.g. `.sh`) from chained types (e.g. `.sh.ps1`) #311

Open hollowaykeanho opened 7 months ago

hollowaykeanho commented 7 months ago

Description

as titled.

Expected Behavior

both are not picking up anymore extensions.

Current Behavior

both only picks up the extension in chained extensions mode.

Steps to Reproduce [COMPULSORY]

  1. build a polygot shell script that offers to any OS and any ARCH functionalities.
  2. run the CI. notice that .rpm is not packaged due to incompatible type.

Associated Data Files

No response

hollowaykeanho commented 7 months ago

Fix:

diff --git a/automataCI/package_unix-any.sh b/automataCI/package_unix-any.sh
index e176889..06648a1 100644
--- a/automataCI/package_unix-any.sh
+++ b/automataCI/package_unix-any.sh
@@ -155,7 +155,9 @@ for i in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}"/*; do
         TARGET_OS="${TARGET_FILENAME##*_}"
         TARGET_FILENAME="${TARGET_FILENAME%%_*}"
         TARGET_ARCH="${TARGET_OS##*-}"
+        TARGET_ARCH="${TARGET_ARCH%%.*}"
         TARGET_OS="${TARGET_OS%%-*}"
+        TARGET_OS="${TARGET_OS%%.*}"

         if [ "$(STRINGS_Is_Empty "$TARGET_OS")" -eq 0 ] ||
                 [ "$(STRINGS_Is_Empty "$TARGET_ARCH")" -eq 0 ] ||
diff --git a/automataCI/package_windows-any.ps1 b/automataCI/package_windows-any.ps1
index 1981979..472a25e 100644
--- a/automataCI/package_windows-any.ps1
+++ b/automataCI/package_windows-any.ps1
@@ -170,7 +170,9 @@ foreach ($file in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_P
        $TARGET_OS = $TARGET_FILENAME -replace ".*_"
        $TARGET_FILENAME = $TARGET_FILENAME -replace "_.*"
        $TARGET_ARCH = $TARGET_OS -replace ".*-"
+       $TARGET_ARCH = $TARGET_ARCH -replace "\..*$"
        $TARGET_OS = $TARGET_OS -replace "-.*"
+       $TARGET_OS = $TARGET_OS -replace "\..*$"

        if (($(STRINGS-Is-Empty "${TARGET_OS}") -eq 0) -or
                ($(STRINGS-Is-Empty "${TARGET_ARCH}") -eq 0) -or
hollowaykeanho commented 6 months ago

fixed in 004aaae86688a36f6653a341248d9677e5018379