@@ -493,30 +493,31 @@ finalize() {
493493 local version=" ${3:- $FINALIZE_VERSION } "
494494 local max_size_mb=95
495495 local artifact_dir=" $component /artifacts"
496- local artifact_base=" $artifact_dir /$component "
497- local temp_tar=" $artifact_base .tar.gz"
496+ local temp_tar=" $artifact_dir /$component .tar.gz"
498497 local tmpzip_dir=" $artifact_dir /.tmpzip"
499498
500499 mkdir -p " $artifact_dir "
501500
502- # Case 1: single file
503501 if [[ -f " $source_path " ]]; then
504502 log i " Source is a file: $source_path " " $logfile "
505503
506- # If AppImage we don't compress it
507504 if [[ " $source_path " == * .AppImage ]]; then
508505 log i " Detected AppImage file, skipping compression." " $logfile "
509- if [[ " $( realpath " $source_path " ) " != " $( realpath " $artifact_base .AppImage" ) " ]]; then
510- cp -f " $source_path " " $artifact_base .AppImage" || { log e " Failed to copy AppImage." " $logfile " ; exit 1; }
506+ local target_path=" $artifact_dir /$component .AppImage"
507+
508+ if [[ " $( realpath " $source_path " ) " != " $( realpath " $target_path " ) " ]]; then
509+ cp -f " $source_path " " $target_path " || { log e " Failed to copy AppImage." " $logfile " ; exit 1; }
511510 else
512511 log i " Source and destination are the same file, skipping copy." " $logfile "
513512 fi
514- chmod +x " $artifact_base .AppImage"
515- sha256sum " $artifact_base .AppImage" > " $artifact_base .AppImage.sha"
516513
517- # Otherwise, split if required
514+ chmod +x " $target_path "
515+ sha256sum " $target_path " > " $target_path .sha"
516+
518517 else
519518 local artifact_size_mb=$(( $(stat - c% s "$source_path ") / 1024 / 1024 ))
519+ local filename=$( basename " $source_path " )
520+ local target_path=" $artifact_dir /$filename "
520521
521522 if [[ " $artifact_size_mb " -gt " $max_size_mb " && " $SPLIT " == " true" ]]; then
522523 log i " Large file detected and SPLIT=true. Creating split ZIP..." " $logfile "
@@ -530,16 +531,15 @@ finalize() {
530531 done
531532 else
532533 log i " Copying file as-is (no split)." " $logfile "
533- if [[ " $source_path " != " $artifact_base " ]]; then
534- cp -f " $source_path " " $artifact_base " || { log e " Copy failed." " $logfile " ; exit 1; }
534+ if [[ " $( realpath " $ source_path" ) " != " $( realpath " $target_path " ) " ]]; then
535+ cp -f " $source_path " " $target_path " || { log e " Copy failed." " $logfile " ; exit 1; }
535536 else
536537 log i " Source and destination are the same file, skipping copy." " $logfile "
537538 fi
538- sha256sum " $artifact_base " > " $artifact_base .sha"
539+ sha256sum " $target_path " > " $target_path .sha"
539540 fi
540541 fi
541542
542- # Case 2: Directory
543543 elif [[ -d " $source_path " ]]; then
544544 log i " Source is a directory." " $logfile "
545545
@@ -574,6 +574,7 @@ finalize() {
574574 rm -rf " $artifact_dir /.tmp"
575575}
576576
577+
577578write_components_version () {
578579
579580 log d " Starting write_components_version function" " $logfile "
0 commit comments