Commit 3319bd391d

3319bd391d1d70676c88b2ba32e971e55493c1ef

parent: 907a8351ba

Unsigned

cmc <hello@cleberg.net> · 2026-10-29 00:52 UTC

Add an App Store release script (!67)

`Scripts/release-ios.sh` archives the app with its widget and share extension
and uploads to App Store Connect, signed automatically through the Apple ID
signed in to Xcode. `DOMAIN_DIG_PUBLISH=0` archives and exports the `.ipa` to
`.build/ios-release` without uploading.

Adapted from moonrise's `scripts/release-ios.sh`, with two deliberate
differences.

## The build number

moonrise derives it from the commit count. This project does not: it sets
`CURRENT_PROJECT_VERSION` by hand at each cut, states it in the cut's commit
message, and the tag describes it. Deriving it here would make the committed
value a lie — the current values are 55 committed against 244 commits — and the
two would drift from the first upload onward. moonrise has no such convention,
so a commit count costs it nothing.

The script also reads the version back out of the built archive rather than
trusting the project file. That is the check the cuts have been making by hand,
and it exists because Xcode has twice migrated Info.plist keys out from under
this project mid-cut.

## The preflight

Stricter than moonrise's clean-tree-and-main, because this project tags every
release. Publishing requires:

- a clean tree and `main`;
- `v<MARKETING_VERSION>` to exist and point at `HEAD`, so an upload cannot carry
  code the tag does not;
- `ReleaseNotes.json` to match `MARKETING_VERSION` — a gap noted during the
  5.5.0 cut, where the unit suite asserts the notes parse but not that they
  describe this build;
- `MARKETING_VERSION` and `CURRENT_PROJECT_VERSION` to be single-valued across
  all ten configurations.

No xcodegen step: this project checks its `.xcodeproj` in, so the versions come
from the pbxproj.

## What was and was not verified

Exercised: the tag guard (correctly refuses right now, since `main` is one
commit past `v5.5.2`), the release-notes guard, and the single-value extraction
in both directions — `MARKETING_VERSION` resolves to 5.5.2 and
`CURRENT_PROJECT_VERSION` to 55, while `PRODUCT_BUNDLE_IDENTIFIER` is correctly
refused as differing.

**Not exercised: the archive, export and upload.** Those sign against the
developer account, and `-allowProvisioningUpdates` can create provisioning
profiles on it. Nothing has been uploaded to Apple.

Layout: unified · split

Docs/ARCHITECTURE.txt +19
@@ -87,6 +87,25 @@ Two test targets run from the `DomainDig` scheme's test action:
87 87
88A plain `xcodebuild test` (and CI) runs both. The unit net went in first in `v5.0.0` and is what made the god-file decomposition safe to attempt. 88A plain `xcodebuild test` (and CI) runs both. The unit net went in first in `v5.0.0` and is what made the god-file decomposition safe to attempt.
89 89
90## Releasing
91
92`Scripts/release-ios.sh` archives the app with its widget and share extension
93and uploads the result to App Store Connect, signed automatically through the
94Apple ID signed in to Xcode. `DOMAIN_DIG_PUBLISH=0` archives and exports the
95`.ipa` to `.build/ios-release` without uploading.
96
97The build number is `CURRENT_PROJECT_VERSION` as committed, not a derived
98value: the release cut sets it by hand, states it in the commit message, and it
99is what the tag describes. The script re-reads it from the built archive rather
100than trusting the project file, because Xcode has migrated keys out from under
101this project before.
102
103Publishing is refused unless the tree is clean, the branch is `main`, and
104`v<MARKETING_VERSION>` exists and points at `HEAD` — so an upload cannot carry
105code the tag does not. It also checks `ReleaseNotes.json` against the marketing
106version, which nothing else does; the unit suite asserts the notes parse, not
107that they describe this build.
108
90## Xcode Project Structure 109## Xcode Project Structure
91 110
92`DomainDig.xcodeproj` uses filesystem-synchronized groups for the `DomainDig` folder. Target membership exclusions are therefore important release metadata. Files that should remain in the tree but not compile, such as retired prototypes, must be listed in the appropriate synchronized build file exception set. 111`DomainDig.xcodeproj` uses filesystem-synchronized groups for the `DomainDig` folder. Target membership exclusions are therefore important release metadata. Files that should remain in the tree but not compile, such as retired prototypes, must be listed in the appropriate synchronized build file exception set.
Scripts/release-ios.sh added +133
@@ -0,0 +1,133 @@
1#!/usr/bin/env bash
2#
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
5# certificate through the Apple ID signed in to Xcode. The upload appears in
6# TestFlight once processed, and can then be chosen for a submission.
7#
8# ./Scripts/release-ios.sh # archive, export and upload
9# DOMAIN_DIG_PUBLISH=0 ./Scripts/release-ios.sh
10# # archive and export the .ipa only
11#
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
16# 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
18# instead would make the committed value a lie, and the two would drift apart
19# from the first upload. moonrise has no such convention, so a commit count
20# costs it nothing.
21#
22# The preflight is stricter, because this project tags every release. A publish
23# requires HEAD to be the commit that v<version> points at, so an upload cannot
24# carry code the tag does not. It also checks the bundled release notes against
25# the marketing version, which nothing else does — the unit suite asserts the
26# notes parse, not that they describe this build.
27
28set -euo pipefail
29
30cd "$(dirname "$0")/.."
31
32PROJECT="DomainDig.xcodeproj"
33SCHEME="DomainDig"
34TEAM="ZCNAX3VL9D"
35PUBLISH="${DOMAIN_DIG_PUBLISH:-1}"
36OUT=".build/ios-release"
37
38fail() {
39 echo "release-ios: $1" >&2
40 exit 1
41}
42
43# One value across all ten configurations, or the archive would disagree with
44# the tag depending on which target you read.
45single_setting() {
46 local key="$1" values
47 values="$(grep -oE "$key = [^;]+;" "$PROJECT/project.pbxproj" | sed -E "s/$key = (.*);/\1/" | sort -u)"
48 [ "$(printf '%s\n' "$values" | wc -l | tr -d ' ')" = 1 ] \
49 || fail "$key differs across configurations: $(printf '%s' "$values" | tr '\n' ' ')"
50 printf '%s' "$values"
51}
52
53version="$(single_setting MARKETING_VERSION)"
54build="$(single_setting CURRENT_PROJECT_VERSION)"
55
56notes_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
62if [ "$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 \
66 || fail "no tag v$version — cut the release first"
67 [ "$(git rev-parse "v$version^{commit}")" = "$(git rev-parse HEAD)" ] \
68 || fail "v$version does not point at HEAD"
69fi
70
71echo "==> DomainDig $version ($build)"
72
73rm -rf "${OUT:?}"
74mkdir -p "$OUT"
75archive="$OUT/DomainDig.xcarchive"
76
77echo "==> Archiving"
78xcodebuild 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.
90plist="$archive/Products/Applications/DomainDig.app/Info.plist"
91built_version="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$plist")"
92built_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
96if [ "$PUBLISH" = 0 ]; then destination=export; else destination=upload; fi
97cat > "$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>
116PLIST
117
118echo "==> ${destination^}ing"
119xcodebuild -exportArchive \
120 -archivePath "$archive" \
121 -exportOptionsPlist "$OUT/ExportOptions.plist" \
122 -exportPath "$OUT/export" \
123 -allowProvisioningUpdates \
124 -quiet
125
126echo
127if [ "$PUBLISH" = 0 ]; then
128 echo "==> Exported $(ls "$OUT"/export/*.ipa 2>/dev/null | head -1)"
129 echo " DomainDig $version ($build). Not uploaded."
130else
131 echo "==> Uploaded DomainDig $version ($build) to App Store Connect."
132 echo " It appears in TestFlight once processing finishes."
133fi