@@ -199,22 +199,118 @@ jobs:
199199 run : |
200200 set -euo pipefail
201201
202- publish_dir="${GITHUB_WORKSPACE}/Publish"
203- if [[ ! -d "${publish_dir}" ]]; then
204- echo "::error::Publish directory not found at ${publish_dir}."
205- echo "Export build directory: '${{ steps.export.outputs.build_directory }}'"
206- exit 1
207- fi
208-
209202 artifacts_dir="${RUNNER_TEMP}/release-artifacts"
210203 rm -rf "${artifacts_dir}"
211204 mkdir -p "${artifacts_dir}"
212205
213- cp "${publish_dir}/MacOS/NetDex.zip" "${artifacts_dir}/netdex-macos-universal.zip"
214- cp "${publish_dir}/Windows/x86/NetDex.zip" "${artifacts_dir}/netdex-windows-x86_64.zip"
215- cp "${publish_dir}/Windows/arm/NetDex.zip" "${artifacts_dir}/netdex-windows-arm64.zip"
216- cp "${publish_dir}/Linux/NetDex.zip" "${artifacts_dir}/netdex-linux-x64.zip"
217- cp "${publish_dir}/Android/NetDex.apk" "${artifacts_dir}/netdex-android-arm64.apk"
206+ build_dir="${{ steps.export.outputs.build_directory }}"
207+ search_roots=(
208+ "${GITHUB_WORKSPACE}/Publish"
209+ "${GITHUB_WORKSPACE}/src/Publish"
210+ "${build_dir}"
211+ "${GITHUB_WORKSPACE}"
212+ )
213+
214+ resolve_file_by_relpath() {
215+ local relpath="$1"
216+ local root
217+ for root in "${search_roots[@]}"; do
218+ [[ -d "${root}" ]] || continue
219+ if [[ -f "${root}/${relpath}" ]]; then
220+ echo "${root}/${relpath}"
221+ return 0
222+ fi
223+ done
224+ return 1
225+ }
226+
227+ find_file_by_path_glob() {
228+ local glob="$1"
229+ local root
230+ for root in "${search_roots[@]}"; do
231+ [[ -d "${root}" ]] || continue
232+ local hit
233+ hit="$(find "${root}" -type f -path "${glob}" | head -n1 || true)"
234+ if [[ -n "${hit}" ]]; then
235+ echo "${hit}"
236+ return 0
237+ fi
238+ done
239+ return 1
240+ }
241+
242+ find_dir_by_path_glob() {
243+ local glob="$1"
244+ local root
245+ for root in "${search_roots[@]}"; do
246+ [[ -d "${root}" ]] || continue
247+ local hit
248+ hit="$(find "${root}" -type d -path "${glob}" | head -n1 || true)"
249+ if [[ -n "${hit}" ]]; then
250+ echo "${hit}"
251+ return 0
252+ fi
253+ done
254+ return 1
255+ }
256+
257+ echo "Artifact discovery roots:"
258+ printf ' - %s\n' "${search_roots[@]}"
259+
260+ mac_source="$(resolve_file_by_relpath "MacOS/NetDex.zip" || true)"
261+ if [[ -z "${mac_source}" ]]; then
262+ mac_source="$(find_file_by_path_glob "*/MacOS/NetDex.zip" || true)"
263+ fi
264+ if [[ -n "${mac_source}" ]]; then
265+ cp "${mac_source}" "${artifacts_dir}/netdex-macos-universal.zip"
266+ else
267+ mac_app_dir="$(find_dir_by_path_glob "*/MacOS/NetDex.app" || true)"
268+ if [[ -z "${mac_app_dir}" ]]; then
269+ echo "::error::Unable to locate macOS export output (NetDex.zip or NetDex.app)."
270+ exit 1
271+ fi
272+ (cd "$(dirname "${mac_app_dir}")" && zip -r -q "${artifacts_dir}/netdex-macos-universal.zip" "$(basename "${mac_app_dir}")")
273+ fi
274+
275+ win_x86_source="$(resolve_file_by_relpath "Windows/x86/NetDex.zip" || true)"
276+ if [[ -z "${win_x86_source}" ]]; then
277+ win_x86_source="$(find_file_by_path_glob "*/Windows/x86/NetDex.zip" || true)"
278+ fi
279+ if [[ -z "${win_x86_source}" ]]; then
280+ echo "::error::Unable to locate Windows x86_64 export output."
281+ exit 1
282+ fi
283+ cp "${win_x86_source}" "${artifacts_dir}/netdex-windows-x86_64.zip"
284+
285+ win_arm_source="$(resolve_file_by_relpath "Windows/arm/NetDex.zip" || true)"
286+ if [[ -z "${win_arm_source}" ]]; then
287+ win_arm_source="$(find_file_by_path_glob "*/Windows/arm/NetDex.zip" || true)"
288+ fi
289+ if [[ -z "${win_arm_source}" ]]; then
290+ echo "::error::Unable to locate Windows ARM64 export output."
291+ exit 1
292+ fi
293+ cp "${win_arm_source}" "${artifacts_dir}/netdex-windows-arm64.zip"
294+
295+ linux_source="$(resolve_file_by_relpath "Linux/NetDex.zip" || true)"
296+ if [[ -z "${linux_source}" ]]; then
297+ linux_source="$(find_file_by_path_glob "*/Linux/NetDex.zip" || true)"
298+ fi
299+ if [[ -z "${linux_source}" ]]; then
300+ echo "::error::Unable to locate Linux export output."
301+ exit 1
302+ fi
303+ cp "${linux_source}" "${artifacts_dir}/netdex-linux-x64.zip"
304+
305+ android_source="$(resolve_file_by_relpath "Android/NetDex.apk" || true)"
306+ if [[ -z "${android_source}" ]]; then
307+ android_source="$(find_file_by_path_glob "*/Android/NetDex.apk" || true)"
308+ fi
309+ if [[ -z "${android_source}" ]]; then
310+ echo "::error::Unable to locate Android export output."
311+ exit 1
312+ fi
313+ cp "${android_source}" "${artifacts_dir}/netdex-android-arm64.apk"
218314
219315 ls -lah "${artifacts_dir}"
220316 echo "artifacts_dir=${artifacts_dir}" >> "${GITHUB_OUTPUT}"
0 commit comments