Skip to content

Commit 8e36612

Browse files
committed
ci: locate macOS bundles via find instead of hard paths
1 parent ac1db60 commit 8e36612

File tree

1 file changed

+17
-45
lines changed

1 file changed

+17
-45
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -163,58 +163,30 @@ jobs:
163163
# Format: rustfs-launcher-{os}-{arch}-{version}
164164
ARTIFACT_PREFIX="rustfs-launcher-${{ matrix.os_name }}-${{ matrix.arch }}-${VERSION}"
165165
166-
# 构建产物目录(兼容 src-tauri/target 与 workspace target)
167-
DMG_DIR=""
168-
BUNDLE_DIR=""
169-
DMG_CANDIDATES=(
170-
"src-tauri/target/${{ matrix.rust_target }}/release/bundle/dmg"
171-
"target/${{ matrix.rust_target }}/release/bundle/dmg"
172-
"src-tauri/target/release/bundle/dmg"
173-
"target/release/bundle/dmg"
174-
)
175-
BUNDLE_CANDIDATES=(
176-
"src-tauri/target/${{ matrix.rust_target }}/release/bundle/macos"
177-
"target/${{ matrix.rust_target }}/release/bundle/macos"
178-
"src-tauri/target/release/bundle/macos"
179-
"target/release/bundle/macos"
180-
)
181-
182-
for d in "${DMG_CANDIDATES[@]}"; do
183-
if [ -d "$d" ]; then DMG_DIR="$d"; break; fi
184-
done
185-
for d in "${BUNDLE_CANDIDATES[@]}"; do
186-
if [ -d "$d" ]; then BUNDLE_DIR="$d"; break; fi
187-
done
166+
# 在 workspace 内搜索打包输出,不依赖固定路径
167+
mapfile -t APP_DIRS < <(find src-tauri target -path "*bundle/macos/*.app" -type d 2>/dev/null || true)
168+
mapfile -t DMG_FILES < <(find src-tauri target -path "*bundle/dmg/*.dmg" -type f 2>/dev/null || true)
188169
189-
if [ -z "$DMG_DIR" ] && [ -z "$BUNDLE_DIR" ]; then
190-
echo "❌ 未找到打包输出目录,尝试过:"
191-
printf ' - %s\n' "${DMG_CANDIDATES[@]}" "${BUNDLE_CANDIDATES[@]}"
192-
echo "目录列表:"
193-
ls -la src-tauri || true
194-
ls -la target || true
195-
exit 1
196-
fi
170+
echo "发现的 .app 目录:" && printf ' - %s\n' "${APP_DIRS[@]:-无}"
171+
echo "发现的 .dmg 文件:" && printf ' - %s\n' "${DMG_FILES[@]:-无}"
197172
198173
# Copy and rename DMG
199-
if [ -d "$DMG_DIR" ]; then
200-
for dmg in "$DMG_DIR"/*.dmg; do
201-
if [ -f "$dmg" ]; then
202-
cp "$dmg" "artifacts/${ARTIFACT_PREFIX}.dmg"
203-
echo "✅ Created: ${ARTIFACT_PREFIX}.dmg"
204-
fi
205-
done
174+
if [ ${#DMG_FILES[@]} -gt 0 ]; then
175+
cp "${DMG_FILES[0]}" "artifacts/${ARTIFACT_PREFIX}.dmg"
176+
echo "✅ Created: ${ARTIFACT_PREFIX}.dmg"
206177
fi
207178
208179
# Create and rename app.zip
209-
if [ -d "$BUNDLE_DIR" ]; then
210-
cd "$BUNDLE_DIR"
211-
app_files=(*.app)
212-
if [ ${#app_files[@]} -eq 0 ]; then
213-
echo "❌ 未找到 .app 产物,检查打包输出目录:$BUNDLE_DIR"
214-
exit 1
215-
fi
216-
zip -r "$GITHUB_WORKSPACE/artifacts/${ARTIFACT_PREFIX}.app.zip" "${app_files[@]}"
180+
if [ ${#APP_DIRS[@]} -gt 0 ]; then
181+
FIRST_APP="${APP_DIRS[0]}"
182+
APP_PARENT="$(dirname "$FIRST_APP")"
183+
APP_NAME="$(basename "$FIRST_APP")"
184+
cd "$APP_PARENT"
185+
zip -r "$GITHUB_WORKSPACE/artifacts/${ARTIFACT_PREFIX}.app.zip" "$APP_NAME"
217186
echo "✅ Created: ${ARTIFACT_PREFIX}.app.zip"
187+
else
188+
echo "❌ 未找到 .app 产物"
189+
exit 1
218190
fi
219191
220192
# Create latest version files

0 commit comments

Comments
 (0)