build.sh 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. #!/bin/bash
  2. ##################################################################################
  3. # Custom build tool for Realm Objective-C binding.
  4. #
  5. # (C) Copyright 2011-2022 by realm.io.
  6. ##################################################################################
  7. # Warning: pipefail is not a POSIX compatible option, but on macOS it works just fine.
  8. # macOS uses a POSIX complain version of bash as /bin/sh, but apparently it does
  9. # not strip away this feature. Also, this will fail if somebody forces the script
  10. # to be run with zsh.
  11. set -o pipefail
  12. set -e
  13. readonly source_root="$(dirname "$0")"
  14. : "${REALM_CORE_VERSION:=$(sed -n 's/^REALM_CORE_VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")}" # set to "current" to always use the current build
  15. # You can override the xcmode used
  16. : "${XCMODE:=xcodebuild}" # must be one of: xcodebuild (default), xcpretty, xctool
  17. # Provide a fallback value for TMPDIR, relevant for Xcode Bots
  18. : "${TMPDIR:=$(getconf DARWIN_USER_TEMP_DIR)}"
  19. PATH=/usr/libexec:$PATH
  20. if [ -n "${JENKINS_HOME}" ]; then
  21. XCPRETTY_PARAMS=(--no-utf --report junit --output build/reports/junit.xml)
  22. CODESIGN_PARAMS=(CODE_SIGN_IDENTITY='' CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO)
  23. fi
  24. usage() {
  25. cat <<EOF
  26. Usage: sh $0 command [argument]
  27. command:
  28. clean: clean up/remove all generated files
  29. download-core: downloads core library (binary version)
  30. build [platforms]: builds xcframeworks for Realm and RealmSwift for given platforms (default all)
  31. build-static [plats]: builds static xcframework for Realm platforms (default all)
  32. analyze-osx: analyzes macOS framework
  33. test: tests all iOS and macOS frameworks
  34. test-all: tests all iOS and macOS frameworks in both Debug and Release configurations
  35. test-ios-static: tests static iOS framework on 32-bit and 64-bit simulators
  36. test-ios-dynamic: tests dynamic iOS framework on 32-bit and 64-bit simulators
  37. test-ios-swift: tests RealmSwift iOS framework on 32-bit and 64-bit simulators
  38. test-ios-devices: tests ObjC & Swift iOS frameworks on all attached iOS devices
  39. test-ios-devices-objc: tests ObjC iOS framework on all attached iOS devices
  40. test-ios-devices-swift: tests Swift iOS framework on all attached iOS devices
  41. test-tvos: tests tvOS framework
  42. test-tvos-swift: tests RealmSwift tvOS framework
  43. test-tvos-devices: tests ObjC & Swift tvOS frameworks on all attached tvOS devices
  44. test-osx: tests macOS framework
  45. test-osx-swift: tests RealmSwift macOS framework
  46. test-catalyst: tests Mac Catalyst framework
  47. test-catalyst-swift: tests RealmSwift Mac Catalyst framework
  48. test-swiftpm: tests ObjC and Swift macOS frameworks via SwiftPM
  49. test-swiftui-ios: tests SwiftUI framework UI tests
  50. test-swiftui-server-osx: tests Server Sync in SwiftUI
  51. verify: verifies docs, osx, osx-swift, ios-static, ios-dynamic, ios-swift, ios-device, swiftui-ios in both Debug and Release configurations, swiftlint, ios-xcode-spm
  52. verify-osx-object-server: downloads the Realm Object Server and runs the Objective-C and Swift integration tests
  53. docs: builds docs in docs/output
  54. examples: builds all examples
  55. examples-ios: builds all static iOS examples
  56. examples-ios-swift: builds all Swift iOS examples
  57. examples-osx: builds all macOS examples
  58. get-version: get the current version
  59. get-ioplatformuuid: get io platform uuid
  60. set-version version: set the version
  61. set-core-version version: set the version of core to use
  62. package platform: build release package for the given platform
  63. package-release: assemble per-platform release packages into a combined one
  64. package-docs: build release package the docs
  65. package-examples: build release package the examples
  66. package-test-examples: test a built examples release package
  67. test-package-release: locally build a complete release package for all platforms
  68. publish-tag branch: create and push a git tag for the given branch
  69. publish-github: create a Github release for the currently checked-out tag
  70. publish-docs: publish a built docs release to the website
  71. publish-cocoapods tag: publish the requested tag to CocoaPods
  72. argument:
  73. version: version in the x.y.z format
  74. platform: exactly one of "osx ios watchos tvos visionos"
  75. platforms: one or more of "osx ios watchos tvos visionos"
  76. environment variables:
  77. XCMODE: xcodebuild (default), xcpretty or xctool
  78. CONFIGURATION: Debug, Release (default), or Static
  79. REALM_CORE_VERSION: version in x.y.z format or "current" to use local build
  80. REALM_EXTRA_BUILD_ARGUMENTS: additional arguments to pass to the build tool
  81. REALM_XCODE_VERSION: the version number of Xcode to use (e.g.: 13.3.1)
  82. REALM_XCODE_OLDEST_VERSION: the version number of oldest available Xcode to use (e.g.: 12.4)
  83. REALM_XCODE_LATEST_VERSION: the version number of latest available Xcode to use (e.g.: 13.3.1)
  84. EOF
  85. }
  86. ######################################
  87. # Xcode Helpers
  88. ######################################
  89. xcode_version_major() {
  90. echo "${REALM_XCODE_VERSION%%.*}"
  91. }
  92. xcode() {
  93. mkdir -p build/DerivedData
  94. CMD="xcodebuild -IDECustomDerivedDataLocation=build/DerivedData"
  95. echo "Building with command: $CMD $*"
  96. xcodebuild -IDECustomDerivedDataLocation=build/DerivedData "$@"
  97. }
  98. xc() {
  99. # Logs xcodebuild output in realtime
  100. : "${NSUnbufferedIO:=YES}"
  101. if [[ "$XCMODE" == "xcodebuild" ]]; then
  102. xcode "$@" "${REALM_EXTRA_BUILD_ARGUMENTS[@]}"
  103. elif [[ "$XCMODE" == "xcpretty" ]]; then
  104. mkdir -p build
  105. xcode "$@" "${REALM_EXTRA_BUILD_ARGUMENTS[@]}" | tee build/build.log | xcpretty -c "${XCPRETTY_PARAMS[@]}" || {
  106. echo "The raw xcodebuild output is available in build/build.log"
  107. exit 1
  108. }
  109. elif [[ "$XCMODE" == "xctool" ]]; then
  110. xctool "$@" "${REALM_EXTRA_BUILD_ARGUMENTS[@]}"
  111. fi
  112. }
  113. xctest() {
  114. local scheme="$1"
  115. xc -scheme "$scheme" "${@:2}" build-for-testing
  116. xc -scheme "$scheme" "${@:2}" test-without-building
  117. }
  118. build_combined() {
  119. local product="$1"
  120. local platform="$2"
  121. local config="$CONFIGURATION"
  122. local config_suffix simulator_suffix destination build_args
  123. case "$platform" in
  124. osx)
  125. destination='generic/platform=macOS'
  126. config_suffix=
  127. ;;
  128. ios)
  129. destination='generic/platform=iOS'
  130. config_suffix=-iphoneos
  131. simulator_suffix=iphonesimulator
  132. ;;
  133. watchos)
  134. destination='generic/platform=watchOS'
  135. config_suffix=-watchos
  136. simulator_suffix=watchsimulator
  137. ;;
  138. tvos)
  139. destination='generic/platform=tvOS'
  140. config_suffix=-appletvos
  141. simulator_suffix=appletvsimulator
  142. ;;
  143. visionos)
  144. destination='generic/platform=visionOS'
  145. config_suffix=-xros
  146. simulator_suffix=xrsimulator
  147. ;;
  148. catalyst)
  149. destination='generic/platform=macOS,variant=Mac Catalyst'
  150. config_suffix=-maccatalyst
  151. ;;
  152. esac
  153. build_args=(-scheme "$product" -configuration "$config" build REALM_HIDE_SYMBOLS=YES)
  154. # Derive build paths
  155. local build_products_path="build/DerivedData/Realm/Build/Products"
  156. local product_name="$product.framework"
  157. local os_path="$build_products_path/$config${config_suffix}/$product_name"
  158. local simulator_path="$build_products_path/$config-$simulator_suffix/$product_name"
  159. local out_path="build/$config/$platform"
  160. local xcframework_path="$out_path/$product.xcframework"
  161. # Build for each platform
  162. xc -destination "$destination" "${build_args[@]}"
  163. simulator_framework=()
  164. if [[ -n "$simulator_suffix" ]]; then
  165. xc -destination "$destination Simulator" "${build_args[@]}"
  166. simulator_framework+=(-framework "$simulator_path")
  167. fi
  168. # Create the xcframework
  169. rm -rf "$xcframework_path"
  170. xcodebuild -create-xcframework -allow-internal-distribution -output "$xcframework_path" \
  171. -framework "$os_path" "${simulator_framework[@]}"
  172. }
  173. clean_retrieve() {
  174. mkdir -p "$2"
  175. rm -rf "$2/$3"
  176. cp -R "$1" "$2"
  177. }
  178. plist_get() {
  179. /usr/libexec/PlistBuddy -c "Print :$2" "$1" 2> /dev/null
  180. }
  181. ######################################
  182. # Device Test Helper
  183. ######################################
  184. test_devices() {
  185. local serial_numbers=()
  186. local awk_script="
  187. /^ +Vendor ID: / { is_apple = 0; }
  188. /^ +Vendor ID: 0x05[aA][cC] / { is_apple = 1; }
  189. /^ +Serial Number: / {
  190. if (is_apple) {
  191. match(\$0, /^ +Serial Number: /);
  192. print substr(\$0, RLENGTH + 1);
  193. }
  194. }
  195. "
  196. local serial_numbers_text=$(/usr/sbin/system_profiler SPUSBDataType | /usr/bin/awk "$awk_script")
  197. while read -r number; do
  198. if [[ "$number" != "" ]]; then
  199. serial_numbers+=("$number")
  200. fi
  201. done <<< "$serial_numbers_text"
  202. if [[ ${#serial_numbers[@]} == 0 ]]; then
  203. echo "At least one iOS/tvOS device must be connected to this computer to run device tests"
  204. if [ -z "${JENKINS_HOME}" ]; then
  205. # Don't fail if running locally and there's no device
  206. exit 0
  207. fi
  208. exit 1
  209. fi
  210. local sdk="$1"
  211. local scheme="$2"
  212. local configuration="$3"
  213. local failed=0
  214. for device in "${serial_numbers[@]}"; do
  215. xc -scheme "$scheme" -configuration "$configuration" -destination "id=$device" -sdk "$sdk" test || failed=1
  216. done
  217. return $failed
  218. }
  219. ######################################
  220. # Docs
  221. ######################################
  222. build_docs() {
  223. local language="$1"
  224. local version=$(sh build.sh get-version)
  225. local xcodebuild_arguments="--objc,Realm/Realm.h,--,-x,objective-c,-isysroot,$(xcrun --show-sdk-path),-I,$(pwd)"
  226. local module="Realm"
  227. local objc="--objc"
  228. if [[ "$language" == "swift" ]]; then
  229. xcodebuild_arguments="-scheme,RealmSwift"
  230. module="RealmSwift"
  231. objc=""
  232. fi
  233. jazzy \
  234. "${objc}" \
  235. --clean \
  236. --author Realm \
  237. --author_url https://docs.mongodb.com/realm-sdks \
  238. --github_url https://github.com/realm/realm-swift \
  239. --github-file-prefix "https://github.com/realm/realm-swift/tree/v${version}" \
  240. --module-version "${version}" \
  241. --xcodebuild-arguments "${xcodebuild_arguments}" \
  242. --module "${module}" \
  243. --root-url "https://docs.mongodb.com/realm-sdks/${language}/${version}/" \
  244. --output "docs/${language}_output" \
  245. --head "$(cat docs/custom_head.html)" \
  246. --exclude 'RealmSwift/Impl/*'
  247. }
  248. ######################################
  249. # Input Validation
  250. ######################################
  251. if [ "$#" -eq 0 ] || [ "$#" -gt 3 ]; then
  252. usage
  253. exit 1
  254. fi
  255. ######################################
  256. # Variables
  257. ######################################
  258. COMMAND="$1"
  259. # Use Debug config if command ends with -debug, otherwise default to Release
  260. case "$COMMAND" in
  261. *-debug)
  262. COMMAND="${COMMAND%-debug}"
  263. CONFIGURATION="Debug"
  264. ;;
  265. *-static)
  266. COMMAND="${COMMAND%-static}"
  267. CONFIGURATION="Static"
  268. ;;
  269. esac
  270. export CONFIGURATION=${CONFIGURATION:-Release}
  271. # Pre-choose Xcode version for those operations that do not override it
  272. REALM_XCODE_VERSION=${xcode_version:-$REALM_XCODE_VERSION}
  273. source "${source_root}/scripts/swift-version.sh"
  274. set_xcode_version
  275. ######################################
  276. # Commands
  277. ######################################
  278. case "$COMMAND" in
  279. ######################################
  280. # Clean
  281. ######################################
  282. "clean")
  283. find . -type d -name build -exec rm -r "{}" +
  284. exit 0
  285. ;;
  286. ######################################
  287. # Dependencies
  288. ######################################
  289. "download-core")
  290. sh scripts/download-core.sh
  291. exit 0
  292. ;;
  293. "setup-baas")
  294. ruby Realm/ObjectServerTests/setup_baas.rb
  295. exit 0
  296. ;;
  297. "prelaunch-simulator")
  298. if [ -z "$REALM_SKIP_PRELAUNCH" ]; then
  299. sh "${source_root}/scripts/reset-simulators.sh" "$1"
  300. fi
  301. ;;
  302. ######################################
  303. # Building
  304. ######################################
  305. "build")
  306. sh build.sh xcframework
  307. exit 0
  308. ;;
  309. "ios")
  310. build_combined Realm ios
  311. exit 0
  312. ;;
  313. "ios-swift")
  314. build_combined Realm ios
  315. build_combined RealmSwift ios
  316. exit 0
  317. ;;
  318. "watchos")
  319. build_combined Realm watchos
  320. exit 0
  321. ;;
  322. "watchos-swift")
  323. build_combined Realm watchos
  324. build_combined RealmSwift watchos
  325. exit 0
  326. ;;
  327. "tvos")
  328. build_combined Realm tvos
  329. exit 0
  330. ;;
  331. "tvos-swift")
  332. build_combined Realm tvos
  333. build_combined RealmSwift tvos
  334. exit 0
  335. ;;
  336. "osx")
  337. build_combined Realm osx
  338. exit 0
  339. ;;
  340. "osx-swift")
  341. build_combined Realm osx
  342. build_combined RealmSwift osx
  343. exit 0
  344. ;;
  345. "catalyst")
  346. build_combined Realm catalyst
  347. ;;
  348. "catalyst-swift")
  349. build_combined Realm catalyst
  350. build_combined RealmSwift catalyst
  351. ;;
  352. "visionos")
  353. build_combined Realm visionos
  354. ;;
  355. "visionos-swift")
  356. build_combined Realm visionos
  357. build_combined RealmSwift visionos
  358. ;;
  359. "xcframework")
  360. # Build all of the requested frameworks
  361. shift
  362. if (( $(xcode_version_major) < 15 )); then
  363. PLATFORMS="${*:-osx ios watchos tvos catalyst}"
  364. else
  365. PLATFORMS="${*:-osx ios watchos tvos catalyst visionos}"
  366. fi
  367. for platform in $PLATFORMS; do
  368. sh build.sh "$platform-swift"
  369. done
  370. # Assemble them into xcframeworks
  371. rm -rf "build/$CONFIGURATION/"*.xcframework
  372. find "build/$CONFIGURATION" -name 'Realm.framework' \
  373. | sed 's/.*/-framework &/' \
  374. | xargs xcodebuild -create-xcframework -allow-internal-distribution -output "build/$CONFIGURATION/Realm.xcframework"
  375. find "build/$CONFIGURATION" -name 'RealmSwift.framework' \
  376. | sed 's/.*/-framework &/' \
  377. | xargs xcodebuild -create-xcframework -allow-internal-distribution -output "build/$CONFIGURATION/RealmSwift.xcframework"
  378. # Because we have a module named Realm and a type named Realm we need to manually resolve the naming
  379. # collisions that are happening. These collisions create a red herring which tells the user the xcframework
  380. # was compiled with an older Swift version and is not compatible with the current compiler.
  381. find "build/$CONFIGURATION/RealmSwift.xcframework" -name "*.swiftinterface" \
  382. -exec sed -i '' 's/Realm\.//g' {} \; \
  383. -exec sed -i '' 's/import Private/import Realm.Private\nimport Realm.Swift/g' {} \; \
  384. -exec sed -i '' 's/RealmSwift.Configuration/RealmSwift.Realm.Configuration/g' {} \; \
  385. -exec sed -i '' 's/extension Configuration/extension Realm.Configuration/g' {} \; \
  386. -exec sed -i '' 's/RealmSwift.Error[[:>:]]/RealmSwift.Realm.Error/g' {} \; \
  387. -exec sed -i '' 's/extension Error/extension Realm.Error/g' {} \; \
  388. -exec sed -i '' 's/RealmSwift.AsyncOpenTask/RealmSwift.Realm.AsyncOpenTask/g' {} \; \
  389. -exec sed -i '' 's/RealmSwift.UpdatePolicy/RealmSwift.Realm.UpdatePolicy/g' {} \; \
  390. -exec sed -i '' 's/RealmSwift.Notification[[:>:]]/RealmSwift.Realm.Notification/g' {} \; \
  391. -exec sed -i '' 's/RealmSwift.OpenBehavior/RealmSwift.Realm.OpenBehavior/g' {} \; \
  392. -exec sed -i '' 's/τ_1_0/V/g' {} \; # Generics will use τ_1_0 which needs to be changed to the correct type name.
  393. exit 0
  394. ;;
  395. "verify-xcframework-evolution-mode")
  396. export REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS REALM_BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
  397. unset REALM_SWIFT_VERSION
  398. # Build with the oldest supported Xcode version
  399. REALM_XCODE_VERSION=$REALM_XCODE_OLDEST_VERSION sh build.sh xcframework osx
  400. # Try to import the built framework using the newest supported version
  401. cd examples/installation
  402. REALM_XCODE_VERSION=$REALM_XCODE_LATEST_VERSION ./build.rb osx xcframework
  403. exit 0
  404. ;;
  405. ######################################
  406. # Analysis
  407. ######################################
  408. "analyze-osx")
  409. xc -scheme Realm -configuration "$CONFIGURATION" analyze
  410. exit 0
  411. ;;
  412. ######################################
  413. # Testing
  414. ######################################
  415. "test")
  416. set +e # Run both sets of tests even if the first fails
  417. failed=0
  418. sh build.sh test-ios || failed=1
  419. sh build.sh test-ios-swift || failed=1
  420. sh build.sh test-ios-devices || failed=1
  421. sh build.sh test-tvos-devices || failed=1
  422. sh build.sh test-osx || failed=1
  423. sh build.sh test-osx-swift || failed=1
  424. sh build.sh test-catalyst || failed=1
  425. sh build.sh test-catalyst-swift || failed=1
  426. exit $failed
  427. ;;
  428. "test-all")
  429. set +e
  430. failed=0
  431. sh build.sh test || failed=1
  432. sh build.sh test-debug || failed=1
  433. exit $failed
  434. ;;
  435. "test-ios")
  436. xctest Realm -configuration "$CONFIGURATION" -sdk iphonesimulator -destination 'name=iPhone 11'
  437. exit 0
  438. ;;
  439. "test-ios-swift")
  440. xctest RealmSwift -configuration "$CONFIGURATION" -sdk iphonesimulator -destination 'name=iPhone 11'
  441. exit 0
  442. ;;
  443. "test-ios-devices")
  444. failed=0
  445. trap "failed=1" ERR
  446. sh build.sh test-ios-devices-objc
  447. sh build.sh test-ios-devices-swift
  448. exit $failed
  449. ;;
  450. "test-ios-devices-objc")
  451. test_devices iphoneos "Realm" "$CONFIGURATION"
  452. exit $?
  453. ;;
  454. "test-ios-devices-swift")
  455. test_devices iphoneos "RealmSwift" "$CONFIGURATION"
  456. exit $?
  457. ;;
  458. "test-tvos")
  459. destination="Apple TV"
  460. xctest Realm -configuration "$CONFIGURATION" -sdk appletvsimulator -destination "name=$destination"
  461. exit $?
  462. ;;
  463. "test-tvos-swift")
  464. destination="Apple TV"
  465. xctest RealmSwift -configuration "$CONFIGURATION" -sdk appletvsimulator -destination "name=$destination"
  466. exit $?
  467. ;;
  468. "test-tvos-devices")
  469. test_devices appletvos TestHost "$CONFIGURATION"
  470. ;;
  471. "test-osx")
  472. COVERAGE_PARAMS=()
  473. if [[ "$CONFIGURATION" == "Debug" ]]; then
  474. COVERAGE_PARAMS=(GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES)
  475. fi
  476. xctest Realm -configuration "$CONFIGURATION" "${COVERAGE_PARAMS[@]}" -destination "platform=macOS,arch=$(uname -m)"
  477. exit 0
  478. ;;
  479. "test-osx-swift")
  480. xctest RealmSwift -configuration "$CONFIGURATION" -destination "platform=macOS,arch=$(uname -m)"
  481. exit 0
  482. ;;
  483. "test-osx-object-server")
  484. xctest 'Object Server Tests' -configuration "$CONFIGURATION" -sdk macosx -destination "platform=macOS,arch=$(uname -m)"
  485. exit 0
  486. ;;
  487. test-ios-xcode-spm)
  488. cd examples/installation
  489. ./build.rb ios spm
  490. exit 0
  491. ;;
  492. test-swiftpm*)
  493. SANITIZER=$(echo "$COMMAND" | cut -d - -f 3)
  494. # FIXME: throwing an exception from a property getter corrupts Swift's
  495. # runtime exclusivity checking state. Unfortunately, this is something
  496. # we do a lot in tests.
  497. SWIFT_TEST_FLAGS=(-Xcc -g0 -Xswiftc -enforce-exclusivity=none)
  498. if [ -n "$SANITIZER" ]; then
  499. SWIFT_TEST_FLAGS+=(--sanitize "$SANITIZER")
  500. export ASAN_OPTIONS='check_initialization_order=true:detect_stack_use_after_return=true'
  501. fi
  502. xcrun swift package resolve
  503. xcrun swift test --configuration "$(echo "$CONFIGURATION" | tr "[:upper:]" "[:lower:]")" "${SWIFT_TEST_FLAGS[@]}"
  504. exit 0
  505. ;;
  506. "test-swiftui-ios")
  507. xctest 'SwiftUITestHost' -configuration "$CONFIGURATION" -sdk iphonesimulator -destination 'name=iPhone 11'
  508. exit 0
  509. ;;
  510. "test-catalyst")
  511. xctest Realm -configuration "$CONFIGURATION" -destination 'platform=macOS,variant=Mac Catalyst' CODE_SIGN_IDENTITY=''
  512. exit 0
  513. ;;
  514. "test-catalyst-swift")
  515. xctest RealmSwift -configuration "$CONFIGURATION" -destination 'platform=macOS,variant=Mac Catalyst' CODE_SIGN_IDENTITY=''
  516. exit 0
  517. ;;
  518. "test-swiftui-server-osx")
  519. xctest 'SwiftUISyncTestHost' -configuration "$CONFIGURATION" -sdk macosx -destination 'platform=macOS'
  520. exit 0
  521. ;;
  522. ######################################
  523. # Full verification
  524. ######################################
  525. "verify")
  526. sh build.sh verify-cocoapods
  527. sh build.sh verify-docs
  528. sh build.sh verify-osx
  529. sh build.sh verify-osx-debug
  530. sh build.sh verify-osx-swift
  531. sh build.sh verify-osx-swift-debug
  532. sh build.sh verify-ios-static
  533. sh build.sh verify-ios-static-debug
  534. sh build.sh verify-ios-dynamic
  535. sh build.sh verify-ios-dynamic-debug
  536. sh build.sh verify-ios-swift
  537. sh build.sh verify-ios-swift-debug
  538. sh build.sh verify-ios-device-objc
  539. sh build.sh verify-ios-device-swift
  540. sh build.sh verify-watchos
  541. sh build.sh verify-tvos
  542. sh build.sh verify-tvos-debug
  543. sh build.sh verify-tvos-device
  544. sh build.sh verify-swiftlint
  545. sh build.sh verify-swiftpm
  546. sh build.sh verify-osx-object-server
  547. sh build.sh verify-catalyst
  548. sh build.sh verify-catalyst-swift
  549. sh build.sh verify-swiftui-ios
  550. sh build.sh verify-swiftui-server-osx
  551. ;;
  552. "verify-cocoapods")
  553. export REALM_TEST_BRANCH="$sha"
  554. if [[ -d .git ]]; then
  555. # Verify the current branch, unless one was already specified in the sha environment variable.
  556. if [[ -z $sha ]]; then
  557. export REALM_TEST_BRANCH=$(git rev-parse --abbrev-ref HEAD)
  558. fi
  559. if [[ $(git log -1 '@{push}..') != "" ]] || ! git diff-index --quiet HEAD; then
  560. echo "WARNING: verify-cocoapods will test the latest revision of $sha found on GitHub."
  561. echo " Any unpushed local changes will not be tested."
  562. echo ""
  563. sleep 1
  564. fi
  565. fi
  566. cd examples/installation
  567. ./build.rb ios cocoapods static
  568. ./build.rb ios cocoapods dynamic
  569. ./build.rb osx cocoapods
  570. ./build.rb tvos cocoapods
  571. ./build.rb watchos cocoapods
  572. ./build.rb catalyst cocoapods
  573. ;;
  574. verify-cocoapods-ios-dynamic)
  575. cd examples/installation
  576. REALM_TEST_BRANCH="$sha" ./build.rb ios cocoapods
  577. ;;
  578. verify-cocoapods-*)
  579. PLATFORM=$(echo "$COMMAND" | cut -d - -f 3)
  580. cd examples/installation
  581. REALM_TEST_BRANCH="$sha" ./build.rb "$PLATFORM" cocoapods
  582. ;;
  583. "verify-osx-encryption")
  584. REALM_ENCRYPT_ALL=YES sh build.sh test-osx
  585. exit 0
  586. ;;
  587. "verify-osx")
  588. REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS -workspace examples/osx/objc/RealmExamples.xcworkspace" \
  589. sh build.sh test-osx
  590. sh build.sh examples-osx
  591. (
  592. cd examples/osx/objc/build/DerivedData/RealmExamples/Build/Products/$CONFIGURATION
  593. DYLD_FRAMEWORK_PATH=. ./JSONImport >/dev/null
  594. )
  595. exit 0
  596. ;;
  597. "verify-osx-swift-evolution")
  598. export REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS REALM_BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
  599. sh build.sh test-osx-swift
  600. exit 0
  601. ;;
  602. "verify-ios-static")
  603. REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS -workspace examples/ios/objc/RealmExamples.xcworkspace" \
  604. sh build.sh test-ios-static
  605. sh build.sh examples-ios
  606. ;;
  607. "verify-ios-swift")
  608. REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS -workspace examples/ios/swift/RealmExamples.xcworkspace" \
  609. sh build.sh test-ios-swift
  610. sh build.sh examples-ios-swift
  611. ;;
  612. "verify-ios-swift-evolution")
  613. export REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS REALM_BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
  614. sh build.sh test-ios-swift
  615. exit 0
  616. ;;
  617. "verify-docs")
  618. sh build.sh docs
  619. for lang in swift objc; do
  620. undocumented="docs/${lang}_output/undocumented.json"
  621. if ruby -rjson -e "j = JSON.parse(File.read('docs/${lang}_output/undocumented.json')); exit j['warnings'].length != 0"; then
  622. echo "Undocumented Realm $lang declarations:"
  623. cat "$undocumented"
  624. exit 1
  625. fi
  626. done
  627. exit 0
  628. ;;
  629. "verify-watchos")
  630. sh build.sh watchos-swift
  631. exit 0
  632. ;;
  633. "verify-tvos")
  634. REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS -workspace examples/tvos/objc/RealmExamples.xcworkspace" \
  635. sh build.sh test-tvos
  636. sh build.sh examples-tvos
  637. exit 0
  638. ;;
  639. "verify-tvos-swift")
  640. REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS -workspace examples/tvos/swift/RealmExamples.xcworkspace" \
  641. sh build.sh test-tvos-swift
  642. sh build.sh examples-tvos-swift
  643. exit 0
  644. ;;
  645. "verify-tvos-swift-evolution")
  646. export REALM_EXTRA_BUILD_ARGUMENTS="$REALM_EXTRA_BUILD_ARGUMENTS REALM_BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
  647. sh build.sh test-tvos-swift
  648. exit 0
  649. ;;
  650. "verify-swiftlint")
  651. swiftlint lint --strict
  652. exit 0
  653. ;;
  654. verify-swiftpm*)
  655. sh build.sh "test-$(echo "$COMMAND" | cut -d - -f 2-)"
  656. exit 0
  657. ;;
  658. "verify-xcframework")
  659. sh build.sh xcframework osx
  660. exit 0
  661. ;;
  662. "verify-ios-xcode-spm")
  663. REALM_TEST_BRANCH="$sha" sh build.sh test-ios-xcode-spm
  664. exit 0
  665. ;;
  666. verify-*)
  667. sh build.sh "test-$(echo "$COMMAND" | cut -d - -f 2-)"
  668. exit 0
  669. ;;
  670. ######################################
  671. # Docs
  672. ######################################
  673. "docs")
  674. build_docs objc
  675. build_docs swift
  676. exit 0
  677. ;;
  678. ######################################
  679. # Examples
  680. ######################################
  681. "examples")
  682. sh build.sh clean
  683. sh build.sh prelaunch-simulator
  684. export REALM_SKIP_PRELAUNCH=1
  685. sh build.sh examples-ios
  686. sh build.sh examples-ios-swift
  687. sh build.sh examples-osx
  688. sh build.sh examples-tvos
  689. sh build.sh examples-tvos-swift
  690. exit 0
  691. ;;
  692. "examples-ios")
  693. workspace="examples/ios/objc/RealmExamples.xcworkspace"
  694. examples="Simple TableView Migration Backlink GroupedTableView Encryption Draw"
  695. versions="0 1 2 3 4 5"
  696. for example in $examples; do
  697. if [ "$example" = "Migration" ]; then
  698. # The migration example needs to be built for each schema version to ensure each compiles.
  699. for version in $versions; do
  700. xc -workspace "$workspace" -scheme "$example" -configuration "$CONFIGURATION" -sdk iphonesimulator build ARCHS=x86_64 "${CODESIGN_PARAMS[@]}" GCC_PREPROCESSOR_DEFINITIONS="\$(GCC_PREPROCESSOR_DEFINITIONS) SCHEMA_VERSION_$version"
  701. done
  702. else
  703. xc -workspace "$workspace" -scheme "$example" -configuration "$CONFIGURATION" -sdk iphonesimulator build ARCHS=x86_64 "${CODESIGN_PARAMS[@]}"
  704. fi
  705. done
  706. if [ -n "${JENKINS_HOME}" ]; then
  707. xc -workspace "$workspace" -scheme Extension -configuration "$CONFIGURATION" -sdk iphonesimulator build ARCHS=x86_64 "${CODESIGN_PARAMS[@]}"
  708. fi
  709. exit 0
  710. ;;
  711. "examples-ios-swift")
  712. workspace="examples/ios/swift/RealmExamples.xcworkspace"
  713. if [[ ! -d "$workspace" ]]; then
  714. workspace="${workspace/swift/swift-$REALM_XCODE_VERSION}"
  715. fi
  716. examples="Simple TableView Migration Backlink GroupedTableView Encryption AppClip AppClipParent"
  717. versions="0 1 2 3 4 5"
  718. for example in $examples; do
  719. if [ "$example" = "Migration" ]; then
  720. # The migration example needs to be built for each schema version to ensure each compiles.
  721. for version in $versions; do
  722. xc -workspace "$workspace" -scheme "$example" -configuration "$CONFIGURATION" -sdk iphonesimulator build ARCHS=x86_64 "${CODESIGN_PARAMS[@]}" OTHER_SWIFT_FLAGS="\$(OTHER_SWIFT_FLAGS) -DSCHEMA_VERSION_$version"
  723. done
  724. else
  725. xc -workspace "$workspace" -scheme "$example" -configuration "$CONFIGURATION" -sdk iphonesimulator build ARCHS=x86_64 "${CODESIGN_PARAMS[@]}"
  726. fi
  727. done
  728. exit 0
  729. ;;
  730. "examples-osx")
  731. xc -workspace examples/osx/objc/RealmExamples.xcworkspace \
  732. -scheme JSONImport -configuration "${CONFIGURATION}" \
  733. -destination "platform=macOS,arch=$(uname -m)" \
  734. build "${CODESIGN_PARAMS[@]}"
  735. ;;
  736. "examples-tvos")
  737. workspace="examples/tvos/objc/RealmExamples.xcworkspace"
  738. examples="DownloadCache PreloadedData"
  739. for example in $examples; do
  740. xc -workspace "$workspace" -scheme "$example" -configuration "$CONFIGURATION" -sdk appletvsimulator build ARCHS=x86_64 "${CODESIGN_PARAMS[@]}"
  741. done
  742. exit 0
  743. ;;
  744. "examples-tvos-swift")
  745. workspace="examples/tvos/swift/RealmExamples.xcworkspace"
  746. if [[ ! -d "$workspace" ]]; then
  747. workspace="${workspace/swift/swift-$REALM_XCODE_VERSION}"
  748. fi
  749. examples="DownloadCache PreloadedData"
  750. for example in $examples; do
  751. xc -workspace "$workspace" -scheme "$example" -configuration "$CONFIGURATION" -sdk appletvsimulator build ARCHS=x86_64 "${CODESIGN_PARAMS[@]}"
  752. done
  753. exit 0
  754. ;;
  755. ######################################
  756. # Versioning
  757. ######################################
  758. "get-version")
  759. plist_get 'Realm/Realm-Info.plist' 'CFBundleShortVersionString'
  760. exit 0
  761. ;;
  762. "get-ioplatformuuid")
  763. ioreg -d2 -c IOPlatformExpertDevice | awk -F\" '/IOPlatformUUID/{print $(NF-1)}'
  764. exit 0
  765. ;;
  766. "set-version")
  767. realm_version="$2"
  768. version_files="Realm/Realm-Info.plist"
  769. if [ -z "$realm_version" ]; then
  770. echo "You must specify a version."
  771. exit 1
  772. fi
  773. # The bundle version can contain only three groups of digits separated by periods,
  774. # so strip off any -beta.x tag from the end of the version string.
  775. bundle_version=$(echo "$realm_version" | cut -d - -f 1)
  776. for version_file in $version_files; do
  777. PlistBuddy -c "Set :CFBundleVersion $bundle_version" "$version_file"
  778. PlistBuddy -c "Set :CFBundleShortVersionString $realm_version" "$version_file"
  779. done
  780. sed -i '' "s/^VERSION=.*/VERSION=$realm_version/" dependencies.list
  781. sed -i '' "s/^let cocoaVersion =.*/let cocoaVersion = Version(\"$realm_version\")/" Package.swift
  782. sed -i '' "s/x.y.z Release notes (yyyy-MM-dd)/$realm_version Release notes ($(date '+%Y-%m-%d'))/" CHANGELOG.md
  783. exit 0
  784. ;;
  785. "set-core-version")
  786. new_version="$2"
  787. old_version="$(sed -n 's/^REALM_CORE_VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")"
  788. sed -i '' "s/^REALM_CORE_VERSION=.*/REALM_CORE_VERSION=$new_version/" dependencies.list
  789. sed -i '' "s/^let coreVersion =.*/let coreVersion = Version(\"$new_version\")/" Package.swift
  790. sed -i '' "s/Upgraded realm-core from ? to ?/Upgraded realm-core from $old_version to $new_version/" CHANGELOG.md
  791. exit 0
  792. ;;
  793. ######################################
  794. # Continuous Integration
  795. ######################################
  796. "ci-pr")
  797. mkdir -p build/reports
  798. export REALM_DISABLE_ANALYTICS=1
  799. export REALM_DISABLE_UPDATE_CHECKER=1
  800. # FIXME: Re-enable once CI can properly unlock the keychain
  801. export REALM_DISABLE_METADATA_ENCRYPTION=1
  802. # Make sure there aren't any lingering server processes from previous jobs
  803. pkill -9 mongo stitch || true
  804. # strip off the ios|tvos version specifier, e.g. the last part of: `ios-device-objc-ios8`
  805. if [[ "$target" =~ ^((ios|tvos)-device(-(objc|swift))?)(-(ios|tvos)[[:digit:]]+)?$ ]]; then
  806. export target=${BASH_REMATCH[1]}
  807. fi
  808. if [ "$target" = "docs" ]; then
  809. sh build.sh verify-docs
  810. elif [ "$target" = "swiftlint" ]; then
  811. sh build.sh verify-swiftlint
  812. else
  813. export sha=$GITHUB_PR_SOURCE_BRANCH
  814. export REALM_EXTRA_BUILD_ARGUMENTS='GCC_GENERATE_DEBUGGING_SYMBOLS=NO -allowProvisioningUpdates'
  815. if [[ "$target" = *ios* ]] || [[ "$target" = *tvos* ]] || [[ "$target" = *watchos* ]]; then
  816. sh build.sh prelaunch-simulator "$target"
  817. fi
  818. export REALM_SKIP_PRELAUNCH=1
  819. if [[ "$target" = *"server"* ]] || [[ "$target" = "swiftpm"* ]]; then
  820. mkdir .baas
  821. mv build/stitch .baas
  822. source "$(brew --prefix nvm)/nvm.sh" --no-use
  823. nvm install 16.5.0
  824. sh build.sh setup-baas
  825. fi
  826. # Reset CoreSimulator.log
  827. mkdir -p ~/Library/Logs/CoreSimulator
  828. echo > ~/Library/Logs/CoreSimulator/CoreSimulator.log
  829. failed=0
  830. sh build.sh "verify-$target" 2>&1 | tee build/build.log | xcpretty -r junit -o build/reports/junit.xml || failed=1
  831. if [ "$failed" = "1" ] && grep -E 'DTXProxyChannel|DTXChannel|out of date and needs to be rebuilt|operation never finished bootstrapping|thread is already initializing this class' build/build.log ; then
  832. echo "Known Xcode error detected. Running job again."
  833. if grep -E 'out of date and needs to be rebuilt' build/build.log; then
  834. rm -rf build/DerivedData
  835. fi
  836. failed=0
  837. sh build.sh "verify-$target" | tee build/build.log | xcpretty -r junit -o build/reports/junit.xml || failed=1
  838. elif [ "$failed" = "1" ] && tail ~/Library/Logs/CoreSimulator/CoreSimulator.log | grep -E "Operation not supported|Failed to lookup com.apple.coreservices.lsuseractivity.simulatorsupport"; then
  839. echo "Known Xcode error detected. Running job again."
  840. failed=0
  841. sh build.sh "verify-$target" | tee build/build.log | xcpretty -r junit -o build/reports/junit.xml || failed=1
  842. fi
  843. if [ "$failed" = "1" ]; then
  844. set +e
  845. printf "%s" "\n\n***\nbuild/build.log\n***\n\n" && cat build/build.log
  846. printf "%s" "\n\n***\nCoreSimulator.log\n***\n\n" && cat ~/Library/Logs/CoreSimulator/CoreSimulator.log
  847. exit 1
  848. fi
  849. fi
  850. if [ "$target" = "osx" ] && [ "$configuration" = "Debug" ]; then
  851. gcovr -r . -f ".*Realm.*" -e ".*Tests.*" -e ".*core.*" --xml > build/reports/coverage-report.xml
  852. WS=$(pwd | sed "s/\//\\\\\//g")
  853. sed -i ".bak" "s/<source>\./<source>${WS}/" build/reports/coverage-report.xml
  854. fi
  855. ;;
  856. ######################################
  857. # Release packaging
  858. ######################################
  859. "package-docs")
  860. sh scripts/reset-simulators.sh
  861. sh build.sh docs
  862. cd docs
  863. zip -r realm-docs.zip objc_output swift_output
  864. ;;
  865. "package-examples")
  866. ./scripts/package_examples.rb
  867. zip --symlinks -r realm-examples.zip examples -x "examples/installation/*"
  868. ;;
  869. "package-build-scripts")
  870. zip -r build-scripts.zip build.sh dependencies.list scripts examples/installation
  871. ;;
  872. "package-test-examples")
  873. VERSION="$(sed -n 's/^VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")"
  874. dir="realm-swift-${VERSION}"
  875. unzip "${dir}.zip"
  876. cp "$0" "${dir}"
  877. cp -r "${source_root}/scripts" "${dir}"
  878. cd "${dir}"
  879. sh build.sh examples-ios
  880. sh build.sh examples-tvos
  881. sh build.sh examples-osx
  882. sh build.sh examples-ios-swift
  883. sh build.sh examples-tvos-swift
  884. cd ..
  885. rm -rf "${dir}"
  886. ;;
  887. "package")
  888. PLATFORM="$2"
  889. sh build.sh "$PLATFORM-swift"
  890. if [[ "$PLATFORM" == ios ]]; then
  891. sh build.sh "$PLATFORM-static"
  892. else
  893. mkdir -p Static
  894. fi
  895. cd build
  896. zip --symlinks -r "realm-$PLATFORM-$REALM_XCODE_VERSION.zip" "Release/$PLATFORM" "Static/$PLATFORM"
  897. ;;
  898. "package-release")
  899. version="$(sed -n 's/^VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")"
  900. find . -name 'realm-*-1*.zip' -maxdepth 1 \
  901. | sed 's@./realm-[a-z]*-\(.*\).zip@\1@' \
  902. | sort -u --version-sort \
  903. | xargs ./scripts/create-release-package.rb "${WORKSPACE}/pkg" "${version}"
  904. ;;
  905. "test-package-release")
  906. # Generate a release package locally for testing purposes
  907. # Real releases should always be done via Jenkins
  908. if [ -z "${WORKSPACE}" ]; then
  909. echo 'WORKSPACE must be set to a directory to assemble the release in'
  910. exit 1
  911. fi
  912. if [ -d "${WORKSPACE}" ]; then
  913. echo 'WORKSPACE directory should not already exist'
  914. exit 1
  915. fi
  916. REALM_SOURCE="$(pwd)"
  917. mkdir -p "$WORKSPACE"
  918. WORKSPACE="$(cd "$WORKSPACE" && pwd)"
  919. export WORKSPACE
  920. cd "$WORKSPACE"
  921. git clone --recursive "$REALM_SOURCE" realm-swift
  922. cd realm-swift
  923. echo 'Packaging iOS'
  924. sh build.sh package ios
  925. cp "build/realm-ios-$REALM_XCODE_VERSION.zip" .
  926. echo 'Packaging macOS'
  927. sh build.sh package osx
  928. cp "build/realm-osx-$REALM_XCODE_VERSION.zip" .
  929. echo 'Packaging watchOS'
  930. sh build.sh package watchos
  931. cp "build/realm-watchos-$REALM_XCODE_VERSION.zip" .
  932. echo 'Packaging tvOS'
  933. sh build.sh package tvos
  934. cp "build/realm-tvos-$REALM_XCODE_VERSION.zip" .
  935. echo 'Packaging Catalyst'
  936. sh build.sh package catalyst
  937. cp "build/realm-catalyst-$REALM_XCODE_VERSION.zip" .
  938. if (( "$(xcode_version_major)" >= 15 )); then
  939. echo 'Packaging visionOS'
  940. sh build.sh package visionOS
  941. cp "build/realm-visionOS-$REALM_XCODE_VERSION.zip" .
  942. fi
  943. echo 'Packaging examples'
  944. sh build.sh package-examples
  945. echo 'Building final release packages'
  946. export WORKSPACE="${WORKSPACE}/realm-swift"
  947. sh build.sh package-release
  948. echo 'Testing packaged examples'
  949. sh build.sh package-test-examples
  950. ;;
  951. "publish-github")
  952. VERSION="$(sed -n 's/^VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")"
  953. ./scripts/github_release.rb "$VERSION"
  954. ;;
  955. "publish-docs")
  956. VERSION="$(sed -n 's/^VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")"
  957. PRERELEASE_REGEX='alpha|beta|rc|preview'
  958. if [[ $VERSION =~ $PRERELEASE_REGEX ]]; then
  959. exit 0
  960. fi
  961. rm -rf swift_output objc_output
  962. unzip realm-docs.zip
  963. s3cmd put --recursive --acl-public --access_key=${AWS_ACCESS_KEY_ID} --secret_key=${AWS_SECRET_ACCESS_KEY} swift_output/ s3://realm-sdks/docs/realm-sdks/swift/${VERSION}/
  964. s3cmd put --recursive --acl-public --access_key=${AWS_ACCESS_KEY_ID} --secret_key=${AWS_SECRET_ACCESS_KEY} swift_output/ s3://realm-sdks/docs/realm-sdks/swift/latest/
  965. s3cmd put --recursive --acl-public --access_key=${AWS_ACCESS_KEY_ID} --secret_key=${AWS_SECRET_ACCESS_KEY} objc_output/ s3://realm-sdks/docs/realm-sdks/objc/${VERSION}/
  966. s3cmd put --recursive --acl-public --access_key=${AWS_ACCESS_KEY_ID} --secret_key=${AWS_SECRET_ACCESS_KEY} objc_output/ s3://realm-sdks/docs/realm-sdks/objc/latest/
  967. ;;
  968. "publish-update-checker")
  969. VERSION="$(sed -n 's/^VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")"
  970. PRERELEASE_REGEX='alpha|beta|rc|preview'
  971. if [[ $VERSION =~ $PRERELEASE_REGEX ]]; then
  972. exit 0
  973. fi
  974. # update static.realm.io/update/cocoa
  975. printf "%s" "${VERSION}" > cocoa
  976. s3cmd put cocoa s3://static.realm.io/update/
  977. rm cocoa
  978. ;;
  979. "publish-tag")
  980. git clone git@github.com:realm/realm-swift.git
  981. cd realm-swift
  982. git checkout "$2"
  983. VERSION="$(sed -n 's/^VERSION=\(.*\)$/\1/p' dependencies.list)"
  984. git tag -m "Release ${VERSION}" "v${VERSION}"
  985. git push origin "v${VERSION}"
  986. ;;
  987. "publish-cocoapods")
  988. git clone https://github.com/realm/realm-swift
  989. cd realm-swift
  990. git checkout "$2"
  991. ./scripts/reset-simulators.rb
  992. pod trunk push Realm.podspec --verbose --allow-warnings
  993. pod trunk push RealmSwift.podspec --verbose --allow-warnings --synchronous
  994. ;;
  995. "add-empty-changelog")
  996. empty_section=$(cat <<EOS
  997. x.y.z Release notes (yyyy-MM-dd)
  998. =============================================================
  999. ### Enhancements
  1000. * None.
  1001. ### Fixed
  1002. * <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-swift/issues/????), since v?.?.?)
  1003. * None.
  1004. <!-- ### Breaking Changes - ONLY INCLUDE FOR NEW MAJOR version -->
  1005. ### Compatibility
  1006. * Realm Studio: 14.0.1 or later.
  1007. * APIs are backwards compatible with all previous releases in the 10.x.y series.
  1008. * Carthage release for Swift is built with Xcode 15.0.0.
  1009. * CocoaPods: 1.10 or later.
  1010. * Xcode: 14.1-15.0.0.
  1011. ### Internal
  1012. * Upgraded realm-core from ? to ?
  1013. EOS)
  1014. changelog=$(cat CHANGELOG.md)
  1015. echo "$empty_section" > CHANGELOG.md
  1016. echo >> CHANGELOG.md
  1017. echo "$changelog" >> CHANGELOG.md
  1018. ;;
  1019. *)
  1020. echo "Unknown command '$COMMAND'"
  1021. usage
  1022. exit 1
  1023. ;;
  1024. esac