Skip to content

Commit b0dcb4f

Browse files
committed
cleanup: revert change in composeRelease.sh
1 parent e77b30b commit b0dcb4f

File tree

1 file changed

+45
-59
lines changed

1 file changed

+45
-59
lines changed

composeRelease.sh

Lines changed: 45 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -67,34 +67,39 @@ fi
6767

6868
# try to find unity executable
6969
unity_project_version_path="OneSignalExample/ProjectSettings/ProjectVersion.txt"
70-
unity_project_version=$(cat "${unity_project_version_path}" | sed -n 's/^m_EditorVersion: //p')
71-
72-
# Unity project path from CI environment if available
73-
unity_project_path="${UNITY_PROJECT_PATH:-OneSignalExample}"
74-
75-
# Common installation locations (CI, macOS, local)
76-
unity_candidates=(
77-
"/home/runner/Unity/Hub/Editor/${unity_project_version}/Editor/Unity" # Linux (buildalon/unity-setup)
78-
"/Applications/Unity/Hub/Editor/${unity_project_version}/Unity.app/Contents/MacOS/Unity" # macOS
79-
)
80-
81-
unity_executable=""
82-
for candidate in "${unity_candidates[@]}"; do
83-
if [[ -x "$candidate" ]]; then
84-
unity_executable="$candidate"
85-
break
86-
fi
87-
done
70+
unity_project_version=$(cat ${unity_project_version_path} | sed -n 's/^m_EditorVersion: //p')
71+
unity_versions_path="/Applications/Unity/Hub/Editor"
72+
unity_path="${unity_versions_path}/${unity_project_version}"
8873

89-
if [[ -z "$unity_executable" ]]; then
90-
echo "❌ Could not locate Unity executable for version ${unity_project_version}"
91-
echo "Checked the following paths:"
92-
printf ' - %s\n' "${unity_candidates[@]}"
93-
exit 1
94-
else
95-
echo "✅ Found Unity executable: ${unity_executable}"
74+
if [[ ! -d "${unity_versions_path}" ]]
75+
then
76+
echo "Could not find any versions of Unity installed at path: ${unity_versions_path}"
77+
exit 1
78+
elif [[ ! -d "${unity_path}" ]]
79+
then
80+
echo "Could not find Unity ${unity_project_version}"
81+
pushd "${unity_versions_path}" > /dev/null 2>&1
82+
83+
options=(* "Exit")
84+
PS3="Please select an installed Unity version: "
85+
select option in "${options[@]}"
86+
do
87+
if [[ "$option" = "Exit" ]]
88+
then
89+
exit 1
90+
elif [[ "${options[@]}" =~ "$option" ]]
91+
then
92+
echo "Using ${option}"
93+
unity_path="${unity_versions_path}/${option}"
94+
break
95+
fi
96+
done
97+
98+
popd > /dev/null 2>&1
9699
fi
97100

101+
unity_executable="${unity_path}/Unity.app/Contents/MacOS/Unity"
102+
98103
# VERSION file will act as the source of truth
99104
version_filepath="OneSignalExample/Assets/OneSignal/VERSION"
100105
current_version=$(cat "$version_filepath")
@@ -277,45 +282,26 @@ executeUnityMethod() {
277282
local project_path=$1
278283
local build_target=$2
279284
local method_name=$3
280-
local log_dir="${PWD}/logs"
281-
mkdir -p "${log_dir}"
282-
283-
local log_path="${log_dir}/${method_name}-${build_target}-$(date +%Y%m%d%H%M%S).txt"
284-
285-
echo "▶️ Running Unity method: ${method_name} (${build_target})"
286-
echo " Log file: ${log_path}"
287-
288-
# Clean up stale locks before running
289-
pkill -f Unity || true
290-
rm -f "${project_path}/Temp/UnityLockfile"
291-
292-
# Run Unity in batchmode
293-
"${unity_executable}" \
294-
-projectPath "${project_path}" \
295-
-quit \
296-
-batchmode \
297-
-nographics \
298-
-buildTarget "${build_target}" \
299-
-executeMethod "${method_name}" \
300-
-logFile "${log_path}"
301-
285+
local log_path="${PWD}/logs/${method_name}-${build_target}-$(date +%Y%m%d%H%M%S).txt"
286+
287+
${unity_executable} -projectpath "${project_path}"\
288+
-quit\
289+
-batchmode\
290+
-nographics\
291+
-buildTarget "${build_target}"\
292+
-executeMethod "${method_name}"\
293+
-logFile "${log_path}"
294+
302295
local method_result=$?
303-
296+
304297
if [[ ${method_result} -ne 0 ]]; then
305-
echo "❌ Unity method ${method_name} failed with exit code ${method_result}"
306-
echo "----- Unity log tail (last 40 lines) -----"
307-
tail -n 40 "${log_path}" || echo "(no log file found)"
308-
echo "------------------------------------------"
298+
echo "Unity method failed with ${method_result}"
299+
exit ${method_result}
309300
else
310-
echo "✅ Unity method ${method_name} completed successfully"
311-
echo " Full log: ${log_path}"
301+
echo "Unity method completed"
312302
fi
313303
}
314304

315-
echo "Cleaning up Unity locks..."
316-
pkill -f Unity || true
317-
rm -f OneSignalExample/Temp/UnityLockfile
318-
319305
# update project version
320306
projectsettings_path="OneSignalExample/ProjectSettings/ProjectSettings.asset"
321307
executeUnityMethod "OneSignalExample" "Android" "OneSignalSDK.OneSignalPackagePublisher.UpdateProjectVersion"
@@ -349,4 +335,4 @@ gh release create "${new_version}" "${package_path}"\
349335

350336
# return to workspace
351337
git checkout "${current_branch}"
352-
git stash pop
338+
git stash pop

0 commit comments

Comments
 (0)