Commit 8cf9349f6b
Verified · cmc
Layout: unified · split
Docs/ARCHITECTURE.txt +3 −1
| @@ -92,7 +92,9 @@ A plain `xcodebuild test` (and CI) runs both. The unit net went in first in `v5. | |||
| 92 | `Scripts/release-ios.sh` archives the app with its widget and share extension | 92 | `Scripts/release-ios.sh` archives the app with its widget and share extension |
| 93 | and uploads the result to App Store Connect, signed automatically through the | 93 | and uploads the result to App Store Connect, signed automatically through the |
| 94 | Apple ID signed in to Xcode. `DOMAIN_DIG_PUBLISH=0` archives and exports the | 94 | Apple ID signed in to Xcode. `DOMAIN_DIG_PUBLISH=0` archives and exports the |
| 95 | `.ipa` to `.build/ios-release` without uploading. | 95 | `.ipa` to `.build/ios-release` without uploading. The script sources |
| 96 | `release-ios.sh` from appstore-kit, checked out beside this repository or at | ||
| 97 | `$APPSTORE_KIT`. | ||
| 96 | 98 | ||
| 97 | The build number is `CURRENT_PROJECT_VERSION` as committed, not a derived | 99 | The build number is `CURRENT_PROJECT_VERSION` as committed, not a derived |
| 98 | value: the release cut sets it by hand, states it in the commit message, and it | 100 | value: the release cut sets it by hand, states it in the commit message, and it |
Scripts/release-ios.sh +24 −116
| @@ -1,133 +1,41 @@ | |||
| 1 | #!/usr/bin/env bash | 1 | #!/bin/sh |
| 2 | # | 2 | # |
| 3 | # Archive the app, its widget and its share extension, and upload the result to | 3 | # Archive the app, its widget and its share extension, and upload the result to |
| 4 | # App Store Connect. Signed automatically with the team's distribution | 4 | # App Store Connect. The work is done by appstore-kit, checked out beside this |
| 5 | # certificate through the Apple ID signed in to Xcode. The upload appears in | 5 | # repository or at $APPSTORE_KIT. |
| 6 | # TestFlight once processed, and can then be chosen for a submission. | ||
| 7 | # | 6 | # |
| 8 | # ./Scripts/release-ios.sh # archive, export and upload | 7 | # ./Scripts/release-ios.sh # archive, export and upload |
| 9 | # DOMAIN_DIG_PUBLISH=0 ./Scripts/release-ios.sh | 8 | # DOMAIN_DIG_PUBLISH=0 ./Scripts/release-ios.sh |
| 10 | # # archive and export the .ipa only | 9 | # # archive and export the .ipa only |
| 11 | # | 10 | # |
| 12 | # Adapted from moonrise's scripts/release-ios.sh, with two differences that | ||
| 13 | # matter. | ||
| 14 | # | ||
| 15 | # The build number is CURRENT_PROJECT_VERSION as committed, not the commit | 11 | # The build number is CURRENT_PROJECT_VERSION as committed, not the commit |
| 16 | # count. This project sets it by hand at each cut, states it in the cut's | 12 | # count. This project sets it by hand at each cut, states it in the cut's |
| 17 | # commit message, and verifies it against the built product; deriving it here | 13 | # commit message, and verifies it against the built product; deriving it |
| 18 | # instead would make the committed value a lie, and the two would drift apart | 14 | # instead would make the committed value a lie. |
| 19 | # from the first upload. moonrise has no such convention, so a commit count | ||
| 20 | # costs it nothing. | ||
| 21 | # | 15 | # |
| 22 | # The preflight is stricter, because this project tags every release. A publish | 16 | # A publish requires HEAD to be the commit that v<version> points at, so an |
| 23 | # requires HEAD to be the commit that v<version> points at, so an upload cannot | 17 | # upload cannot carry code the tag does not. The bundled release notes are |
| 24 | # carry code the tag does not. It also checks the bundled release notes against | 18 | # checked against the marketing version, which nothing else does — the unit |
| 25 | # the marketing version, which nothing else does — the unit suite asserts the | 19 | # suite asserts the notes parse, not that they describe this build. |
| 26 | # notes parse, not that they describe this build. | ||
| 27 | |||
| 28 | set -euo pipefail | ||
| 29 | |||
| 30 | cd "$(dirname "$0")/.." | ||
| 31 | 20 | ||
| 32 | PROJECT="DomainDig.xcodeproj" | ||
| 33 | SCHEME="DomainDig" | ||
| 34 | TEAM="ZCNAX3VL9D" | ||
| 35 | PUBLISH="${DOMAIN_DIG_PUBLISH:-1}" | 21 | PUBLISH="${DOMAIN_DIG_PUBLISH:-1}" |
| 36 | OUT=".build/ios-release" | 22 | name=DomainDig |
| 37 | 23 | project=DomainDig.xcodeproj | |
| 38 | fail() { | 24 | scheme=DomainDig |
| 39 | echo "release-ios: $1" >&2 | 25 | build_number=committed |
| 40 | exit 1 | 26 | allow_untracked=1 |
| 41 | } | 27 | |
| 42 | 28 | preflight() { | |
| 43 | # One value across all ten configurations, or the archive would disagree with | 29 | notes_version="$( |
| 44 | # the tag depending on which target you read. | 30 | python3 -c 'import json; print(json.load(open("DomainDig/ReleaseNotes.json"))["version"])' |
| 45 | single_setting() { | 31 | )" |
| 46 | local key="$1" values | 32 | [ "$notes_version" = "$version" ] \ |
| 47 | values="$(grep -oE "$key = [^;]+;" "$PROJECT/project.pbxproj" | sed -E "s/$key = (.*);/\1/" | sort -u)" | 33 | || fail "ReleaseNotes.json is $notes_version but MARKETING_VERSION is $version" |
| 48 | [ "$(printf '%s\n' "$values" | wc -l | tr -d ' ')" = 1 ] \ | 34 | [ "$publish" != 0 ] || return 0 |
| 49 | || fail "$key differs across configurations: $(printf '%s' "$values" | tr '\n' ' ')" | ||
| 50 | printf '%s' "$values" | ||
| 51 | } | ||
| 52 | |||
| 53 | version="$(single_setting MARKETING_VERSION)" | ||
| 54 | build="$(single_setting CURRENT_PROJECT_VERSION)" | ||
| 55 | |||
| 56 | notes_version="$( | ||
| 57 | python3 -c 'import json,sys; print(json.load(open("DomainDig/ReleaseNotes.json"))["version"])' | ||
| 58 | )" | ||
| 59 | [ "$notes_version" = "$version" ] \ | ||
| 60 | || fail "ReleaseNotes.json is $notes_version but MARKETING_VERSION is $version" | ||
| 61 | |||
| 62 | if [ "$PUBLISH" != 0 ]; then | ||
| 63 | [ -z "$(git status --porcelain --untracked-files=no)" ] || fail "the working tree has changes" | ||
| 64 | [ "$(git branch --show-current)" = main ] || fail "release from main" | ||
| 65 | git rev-parse -q --verify "refs/tags/v$version" >/dev/null \ | 35 | git rev-parse -q --verify "refs/tags/v$version" >/dev/null \ |
| 66 | || fail "no tag v$version — cut the release first" | 36 | || fail "no tag v$version — cut the release first" |
| 67 | [ "$(git rev-parse "v$version^{commit}")" = "$(git rev-parse HEAD)" ] \ | 37 | [ "$(git rev-parse "v$version^{commit}")" = "$(git rev-parse HEAD)" ] \ |
| 68 | || fail "v$version does not point at HEAD" | 38 | || fail "v$version does not point at HEAD" |
| 69 | fi | 39 | } |
| 70 | |||
| 71 | echo "==> DomainDig $version ($build)" | ||
| 72 | |||
| 73 | rm -rf "${OUT:?}" | ||
| 74 | mkdir -p "$OUT" | ||
| 75 | archive="$OUT/DomainDig.xcarchive" | ||
| 76 | |||
| 77 | echo "==> Archiving" | ||
| 78 | xcodebuild archive \ | ||
| 79 | -project "$PROJECT" \ | ||
| 80 | -scheme "$SCHEME" \ | ||
| 81 | -configuration Release \ | ||
| 82 | -destination 'generic/platform=iOS' \ | ||
| 83 | -archivePath "$archive" \ | ||
| 84 | -allowProvisioningUpdates \ | ||
| 85 | -quiet | ||
| 86 | |||
| 87 | # The same check the release cuts make by hand: the project file is not the | ||
| 88 | # product, and Xcode has migrated Info.plist keys out from under this project | ||
| 89 | # before. | ||
| 90 | plist="$archive/Products/Applications/DomainDig.app/Info.plist" | ||
| 91 | built_version="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$plist")" | ||
| 92 | built_build="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$plist")" | ||
| 93 | [ "$built_version" = "$version" ] || fail "archive is $built_version, expected $version" | ||
| 94 | [ "$built_build" = "$build" ] || fail "archive is build $built_build, expected $build" | ||
| 95 | |||
| 96 | if [ "$PUBLISH" = 0 ]; then destination=export; else destination=upload; fi | ||
| 97 | cat > "$OUT/ExportOptions.plist" <<PLIST | ||
| 98 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 99 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 100 | <plist version="1.0"> | ||
| 101 | <dict> | ||
| 102 | <key>method</key> | ||
| 103 | <string>app-store-connect</string> | ||
| 104 | <key>destination</key> | ||
| 105 | <string>$destination</string> | ||
| 106 | <key>teamID</key> | ||
| 107 | <string>$TEAM</string> | ||
| 108 | <key>signingStyle</key> | ||
| 109 | <string>automatic</string> | ||
| 110 | <key>manageAppVersionAndBuildNumber</key> | ||
| 111 | <false/> | ||
| 112 | <key>uploadSymbols</key> | ||
| 113 | <true/> | ||
| 114 | </dict> | ||
| 115 | </plist> | ||
| 116 | PLIST | ||
| 117 | |||
| 118 | echo "==> ${destination^}ing" | ||
| 119 | xcodebuild -exportArchive \ | ||
| 120 | -archivePath "$archive" \ | ||
| 121 | -exportOptionsPlist "$OUT/ExportOptions.plist" \ | ||
| 122 | -exportPath "$OUT/export" \ | ||
| 123 | -allowProvisioningUpdates \ | ||
| 124 | -quiet | ||
| 125 | 40 | ||
| 126 | echo | 41 | . "${APPSTORE_KIT:-$(dirname "$0")/../../appstore-kit}/release-ios.sh" |
| 127 | if [ "$PUBLISH" = 0 ]; then | ||
| 128 | echo "==> Exported $(ls "$OUT"/export/*.ipa 2>/dev/null | head -1)" | ||
| 129 | echo " DomainDig $version ($build). Not uploaded." | ||
| 130 | else | ||
| 131 | echo "==> Uploaded DomainDig $version ($build) to App Store Connect." | ||
| 132 | echo " It appears in TestFlight once processing finishes." | ||
| 133 | fi | ||