Commit 975f67592f
Unsigned
Layout: unified · split
README.md +4 −3
| @@ -5,8 +5,8 @@ point `APPSTORE_KIT` at it. | |||
| 5 | 5 | ||
| 6 | ## release-ios.sh | 6 | ## release-ios.sh |
| 7 | 7 | ||
| 8 | Archives an app, checks the archive's version and build against the project, and exports or | 8 | Archives an iOS or macOS app, checks the archive's version and build against the project, and |
| 9 | uploads it to App Store Connect. Each app's `scripts/release-ios.sh` sets its options and | 9 | exports or uploads it to App Store Connect. Each app's `scripts/release-ios.sh` sets its options and |
| 10 | sources this file; the options are listed at the top of it. Run from a clean `main`. | 10 | sources this file; the options are listed at the top of it. Run from a clean `main`. |
| 11 | 11 | ||
| 12 | ```sh | 12 | ```sh |
| @@ -19,7 +19,8 @@ spec=App/project.yml | |||
| 19 | . "${APPSTORE_KIT:-$(dirname "$0")/../../appstore-kit}/release-ios.sh" | 19 | . "${APPSTORE_KIT:-$(dirname "$0")/../../appstore-kit}/release-ios.sh" |
| 20 | ``` | 20 | ``` |
| 21 | 21 | ||
| 22 | Extra checks go in a `preflight()` function defined before the `.` line. | 22 | Extra checks go in a `preflight()` function defined before the `.` line. Set `platform=macos` to |
| 23 | archive the Mac app instead; an app on both has one wrapper per platform. | ||
| 23 | 24 | ||
| 24 | ## render-header.sh | 25 | ## render-header.sh |
| 25 | 26 | ||
release-ios.sh +18 −10
| @@ -1,5 +1,5 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | # Archives an iOS app and uploads it to App Store Connect, signed automatically with the team's | 2 | # Archives an iOS or macOS app and uploads it to App Store Connect, signed automatically with the team's |
| 3 | # distribution certificate through the Apple ID signed in to Xcode. The upload shows in TestFlight | 3 | # distribution certificate through the Apple ID signed in to Xcode. The upload shows in TestFlight |
| 4 | # once processed and can then be picked for a submission. | 4 | # once processed and can then be picked for a submission. |
| 5 | # | 5 | # |
| @@ -11,11 +11,12 @@ | |||
| 11 | # the version is read from it rather than from the project file. | 11 | # the version is read from it rather than from the project file. |
| 12 | # build_number commits (default): the commit count, passed to xcodebuild; | 12 | # build_number commits (default): the commit count, passed to xcodebuild; |
| 13 | # committed: CURRENT_PROJECT_VERSION as committed | 13 | # committed: CURRENT_PROJECT_VERSION as committed |
| 14 | # platform ios (default) or macos | ||
| 14 | # team the team ID (default ZCNAX3VL9D) | 15 | # team the team ID (default ZCNAX3VL9D) |
| 15 | # allow_untracked 1 lets untracked files through the clean-tree check (default 0) | 16 | # allow_untracked 1 lets untracked files through the clean-tree check (default 0) |
| 16 | # and may define preflight(), run with $version, $build and $publish set, before archiving. | 17 | # and may define preflight(), run with $version, $build and $publish set, before archiving. |
| 17 | # | 18 | # |
| 18 | # PUBLISH=0 archives and exports the .ipa to .build/ios-release without uploading. Wrappers set | 19 | # PUBLISH=0 archives and exports the .ipa or .pkg to .build/<platform>-release without uploading. Wrappers set |
| 19 | # PUBLISH from their own variable, such as MOONRISE_PUBLISH. | 20 | # PUBLISH from their own variable, such as MOONRISE_PUBLISH. |
| 20 | set -eu | 21 | set -eu |
| 21 | 22 | ||
| @@ -24,6 +25,7 @@ publish="${PUBLISH:-1}" | |||
| 24 | team="${team:-ZCNAX3VL9D}" | 25 | team="${team:-ZCNAX3VL9D}" |
| 25 | build_number="${build_number:-commits}" | 26 | build_number="${build_number:-commits}" |
| 26 | spec="${spec:-}" | 27 | spec="${spec:-}" |
| 28 | platform="${platform:-ios}" | ||
| 27 | 29 | ||
| 28 | fail() { | 30 | fail() { |
| 29 | echo "release-ios: $1" >&2 | 31 | echo "release-ios: $1" >&2 |
| @@ -56,6 +58,12 @@ case "$build_number" in | |||
| 56 | *) fail "build_number is commits or committed, not $build_number" ;; | 58 | *) fail "build_number is commits or committed, not $build_number" ;; |
| 57 | esac | 59 | esac |
| 58 | 60 | ||
| 61 | case "$platform" in | ||
| 62 | ios) destination='generic/platform=iOS' info=Info.plist ;; | ||
| 63 | macos) destination='generic/platform=macOS' info=Contents/Info.plist ;; | ||
| 64 | *) fail "platform is ios or macos, not $platform" ;; | ||
| 65 | esac | ||
| 66 | |||
| 59 | if command -v preflight >/dev/null; then preflight; fi | 67 | if command -v preflight >/dev/null; then preflight; fi |
| 60 | 68 | ||
| 61 | if [ -n "$spec" ]; then | 69 | if [ -n "$spec" ]; then |
| @@ -63,8 +71,8 @@ if [ -n "$spec" ]; then | |||
| 63 | (cd "$(dirname "$spec")" && xcodegen generate --quiet) | 71 | (cd "$(dirname "$spec")" && xcodegen generate --quiet) |
| 64 | fi | 72 | fi |
| 65 | 73 | ||
| 66 | echo "==> $name $version ($build)" | 74 | echo "==> $name $version ($build), $platform" |
| 67 | out=.build/ios-release | 75 | out=".build/$platform-release" |
| 68 | rm -rf "${out:?}" | 76 | rm -rf "${out:?}" |
| 69 | mkdir -p "$out" | 77 | mkdir -p "$out" |
| 70 | archive="$out/$scheme.xcarchive" | 78 | archive="$out/$scheme.xcarchive" |
| @@ -74,18 +82,18 @@ if [ -z "$spec" ]; then | |||
| 74 | trap 'cp "$out/project.pbxproj" "$project/project.pbxproj"' EXIT | 82 | trap 'cp "$out/project.pbxproj" "$project/project.pbxproj"' EXIT |
| 75 | fi | 83 | fi |
| 76 | xcodebuild archive -project "$project" -scheme "$scheme" -configuration Release \ | 84 | xcodebuild archive -project "$project" -scheme "$scheme" -configuration Release \ |
| 77 | -destination 'generic/platform=iOS' -archivePath "$archive" -derivedDataPath "$out/DerivedData" \ | 85 | -destination "$destination" -archivePath "$archive" -derivedDataPath "$out/DerivedData" \ |
| 78 | -allowProvisioningUpdates -quiet MARKETING_VERSION="$version" CURRENT_PROJECT_VERSION="$build" | 86 | -allowProvisioningUpdates -quiet MARKETING_VERSION="$version" CURRENT_PROJECT_VERSION="$build" |
| 79 | 87 | ||
| 80 | # The project file is not the product: check what was built. | 88 | # The project file is not the product: check what was built. |
| 81 | set -- "$archive"/Products/Applications/*.app | 89 | set -- "$archive"/Products/Applications/*.app |
| 82 | plist="$1/Info.plist" | 90 | plist="$1/$info" |
| 83 | built_version="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$plist")" | 91 | built_version="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$plist")" |
| 84 | built_build="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$plist")" | 92 | built_build="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$plist")" |
| 85 | [ "$built_version" = "$version" ] || fail "archive is $built_version, expected $version" | 93 | [ "$built_version" = "$version" ] || fail "archive is $built_version, expected $version" |
| 86 | [ "$built_build" = "$build" ] || fail "archive is build $built_build, expected $build" | 94 | [ "$built_build" = "$build" ] || fail "archive is build $built_build, expected $build" |
| 87 | 95 | ||
| 88 | if [ "$publish" = 0 ]; then destination=export; else destination=upload; fi | 96 | if [ "$publish" = 0 ]; then method=export; else method=upload; fi |
| 89 | cat > "$out/ExportOptions.plist" <<PLIST | 97 | cat > "$out/ExportOptions.plist" <<PLIST |
| 90 | <?xml version="1.0" encoding="UTF-8"?> | 98 | <?xml version="1.0" encoding="UTF-8"?> |
| 91 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | 99 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| @@ -94,7 +102,7 @@ cat > "$out/ExportOptions.plist" <<PLIST | |||
| 94 | <key>method</key> | 102 | <key>method</key> |
| 95 | <string>app-store-connect</string> | 103 | <string>app-store-connect</string> |
| 96 | <key>destination</key> | 104 | <key>destination</key> |
| 97 | <string>$destination</string> | 105 | <string>$method</string> |
| 98 | <key>teamID</key> | 106 | <key>teamID</key> |
| 99 | <string>$team</string> | 107 | <string>$team</string> |
| 100 | <key>signingStyle</key> | 108 | <key>signingStyle</key> |
| @@ -106,12 +114,12 @@ cat > "$out/ExportOptions.plist" <<PLIST | |||
| 106 | </dict> | 114 | </dict> |
| 107 | </plist> | 115 | </plist> |
| 108 | PLIST | 116 | PLIST |
| 109 | echo "==> $destination" | 117 | echo "==> $method" |
| 110 | xcodebuild -exportArchive -archivePath "$archive" -exportOptionsPlist "$out/ExportOptions.plist" \ | 118 | xcodebuild -exportArchive -archivePath "$archive" -exportOptionsPlist "$out/ExportOptions.plist" \ |
| 111 | -exportPath "$out/export" -allowProvisioningUpdates -quiet | 119 | -exportPath "$out/export" -allowProvisioningUpdates -quiet |
| 112 | 120 | ||
| 113 | if [ "$publish" = 0 ]; then | 121 | if [ "$publish" = 0 ]; then |
| 114 | echo "Exported $(ls "$out"/export/*.ipa): $name $version ($build), not uploaded" | 122 | echo "Exported $(ls "$out"/export/*.ipa "$out"/export/*.pkg 2>/dev/null): $name $version ($build), not uploaded" |
| 115 | else | 123 | else |
| 116 | echo "Uploaded $name $version ($build) to App Store Connect; it shows in TestFlight once processed" | 124 | echo "Uploaded $name $version ($build) to App Store Connect; it shows in TestFlight once processed" |
| 117 | fi | 125 | fi |