Files
ucvl-zonghengjia-open-source/ios/Scripts/verify-and-archive.sh
T

63 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
test -n "${DEVELOPMENT_TEAM:-}" || {
echo "请设置 DEVELOPMENT_TEAM(Apple Developer Team ID)。" >&2
exit 1
}
source_version=$(awk '
$1 == "MARKETING_VERSION:" {
value = $2
sub(/^"/, "", value)
sub(/"$/, "", value)
if (value !~ /^[0-9]+\.[0-9]+\.[0-9]+$/ || seen++) exit 1
version = value
}
END {
if (seen != 1 || version == "") exit 1
print version
}
' project.yml) || {
echo "project.yml 必须包含唯一的数字三段 MARKETING_VERSION。" >&2
exit 1
}
archive_path="build/UCVL-Zonghengjia-${source_version}.xcarchive"
simulator_destination=${SIMULATOR_DESTINATION:-'platform=iOS Simulator,name=iPhone 16 Pro'}
if [ -n "${EXPORT_OPTIONS_PLIST:-}" ]; then
test -f "$EXPORT_OPTIONS_PLIST" && test -r "$EXPORT_OPTIONS_PLIST" || {
echo "EXPORT_OPTIONS_PLIST 必须指定可读的发布选项文件。" >&2
exit 1
}
plutil -lint -- "$EXPORT_OPTIONS_PLIST" >/dev/null || {
echo "EXPORT_OPTIONS_PLIST 不是有效的 plist 文件。" >&2
exit 1
}
fi
./Scripts/fetch-libxray.sh
./Scripts/generate-project.sh
xcodebuild \
-project UCVLZonghengjia.xcodeproj \
-scheme UCVLZonghengjia \
-destination "$simulator_destination" \
DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
test
xcodebuild \
-project UCVLZonghengjia.xcodeproj \
-scheme UCVLZonghengjia \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath "$archive_path" \
DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
archive
if [ -n "${EXPORT_OPTIONS_PLIST:-}" ]; then
xcodebuild \
-exportArchive \
-archivePath "$archive_path" \
-exportPath build/export \
-exportOptionsPlist "$EXPORT_OPTIONS_PLIST"
fi