|
| 1 | +# CF Cache Status - Build & Release Commands |
| 2 | +# Usage: just <command> |
| 3 | + |
| 4 | +# Load environment from .env if it exists |
| 5 | +set dotenv-load |
| 6 | + |
| 7 | +# Configuration |
| 8 | +app_name := "CF Cache Status" |
| 9 | +project := "CF Cache Status/CF Cache Status.xcodeproj" |
| 10 | +scheme := "CF Cache Status" |
| 11 | +build_dir := "build" |
| 12 | +archive_path := build_dir / "CacheStatus.xcarchive" |
| 13 | +export_path := build_dir / "export" |
| 14 | +app_path := export_path / "CF Cache Status.app" |
| 15 | +zip_path := build_dir / "CacheStatus.zip" |
| 16 | + |
| 17 | +# Default recipe |
| 18 | +default: |
| 19 | + @just --list |
| 20 | + |
| 21 | +# ============================================================================= |
| 22 | +# Development |
| 23 | +# ============================================================================= |
| 24 | + |
| 25 | +# Build for development (unsigned) |
| 26 | +build-dev: |
| 27 | + xcodebuild -project "{{project}}" \ |
| 28 | + -scheme "{{scheme}}" \ |
| 29 | + -configuration Debug \ |
| 30 | + build \ |
| 31 | + CODE_SIGN_IDENTITY="-" \ |
| 32 | + CODE_SIGNING_REQUIRED=NO |
| 33 | + |
| 34 | +# Build release (unsigned, for testing) |
| 35 | +build-release: |
| 36 | + xcodebuild -project "{{project}}" \ |
| 37 | + -scheme "{{scheme}}" \ |
| 38 | + -configuration Release \ |
| 39 | + build \ |
| 40 | + CODE_SIGN_IDENTITY="-" \ |
| 41 | + CODE_SIGNING_REQUIRED=NO |
| 42 | + |
| 43 | +# Clean Xcode build artifacts |
| 44 | +clean: |
| 45 | + rm -rf "{{build_dir}}" |
| 46 | + xcodebuild -project "{{project}}" -scheme "{{scheme}}" clean |
| 47 | + |
| 48 | +# Open project in Xcode |
| 49 | +xcode: |
| 50 | + open "{{project}}" |
| 51 | + |
| 52 | +# ============================================================================= |
| 53 | +# Release (requires APPLE_ID, APPLE_TEAM_ID, APPLE_APP_PASSWORD) |
| 54 | +# ============================================================================= |
| 55 | + |
| 56 | +# Build, sign, and archive for distribution |
| 57 | +archive: |
| 58 | + #!/usr/bin/env bash |
| 59 | + set -e |
| 60 | + mkdir -p "{{build_dir}}" |
| 61 | + |
| 62 | + xcodebuild archive \ |
| 63 | + -project "{{project}}" \ |
| 64 | + -scheme "{{scheme}}" \ |
| 65 | + -archivePath "{{archive_path}}" \ |
| 66 | + DEVELOPMENT_TEAM="$APPLE_TEAM_ID" \ |
| 67 | + CODE_SIGN_STYLE=Manual \ |
| 68 | + CODE_SIGN_IDENTITY="Developer ID Application" |
| 69 | + |
| 70 | + cat > "{{build_dir}}/ExportOptions.plist" << EOF |
| 71 | + <?xml version="1.0" encoding="UTF-8"?> |
| 72 | + <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 73 | + <plist version="1.0"> |
| 74 | + <dict> |
| 75 | + <key>method</key> |
| 76 | + <string>developer-id</string> |
| 77 | + <key>teamID</key> |
| 78 | + <string>$APPLE_TEAM_ID</string> |
| 79 | + </dict> |
| 80 | + </plist> |
| 81 | + EOF |
| 82 | + |
| 83 | + xcodebuild -exportArchive \ |
| 84 | + -archivePath "{{archive_path}}" \ |
| 85 | + -exportPath "{{export_path}}" \ |
| 86 | + -exportOptionsPlist "{{build_dir}}/ExportOptions.plist" |
| 87 | + |
| 88 | + echo "✓ Archive complete: {{app_path}}" |
| 89 | + |
| 90 | +# Submit app for notarization |
| 91 | +submit: _check-env |
| 92 | + #!/usr/bin/env bash |
| 93 | + set -e |
| 94 | + |
| 95 | + if [[ ! -d "{{app_path}}" ]]; then |
| 96 | + echo "Error: App not found. Run 'just archive' first." |
| 97 | + exit 1 |
| 98 | + fi |
| 99 | + |
| 100 | + echo "Creating zip..." |
| 101 | + ditto -c -k --keepParent "{{app_path}}" "{{zip_path}}" |
| 102 | + |
| 103 | + echo "Submitting for notarization..." |
| 104 | + output=$(xcrun notarytool submit "{{zip_path}}" \ |
| 105 | + --apple-id "$APPLE_ID" \ |
| 106 | + --team-id "$APPLE_TEAM_ID" \ |
| 107 | + --password "$APPLE_APP_PASSWORD" \ |
| 108 | + --output-format json) |
| 109 | + |
| 110 | + submission_id=$(echo "$output" | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4) |
| 111 | + echo "$submission_id" > "{{build_dir}}/.submission_id" |
| 112 | + |
| 113 | + echo "✓ Submitted: $submission_id" |
| 114 | + echo "" |
| 115 | + echo "Check status: just status" |
| 116 | + |
| 117 | +# Check notarization status |
| 118 | +status id="": _check-env |
| 119 | + #!/usr/bin/env bash |
| 120 | + submission_id="{{id}}" |
| 121 | + [[ -z "$submission_id" ]] && submission_id=$(cat "{{build_dir}}/.submission_id" 2>/dev/null) |
| 122 | + |
| 123 | + if [[ -z "$submission_id" ]]; then |
| 124 | + echo "Error: No submission ID. Provide one or run 'just submit' first." |
| 125 | + exit 1 |
| 126 | + fi |
| 127 | + |
| 128 | + xcrun notarytool info "$submission_id" \ |
| 129 | + --apple-id "$APPLE_ID" \ |
| 130 | + --team-id "$APPLE_TEAM_ID" \ |
| 131 | + --password "$APPLE_APP_PASSWORD" |
| 132 | + |
| 133 | +# Wait for notarization to complete |
| 134 | +wait id="": _check-env |
| 135 | + #!/usr/bin/env bash |
| 136 | + submission_id="{{id}}" |
| 137 | + [[ -z "$submission_id" ]] && submission_id=$(cat "{{build_dir}}/.submission_id" 2>/dev/null) |
| 138 | + |
| 139 | + xcrun notarytool wait "$submission_id" \ |
| 140 | + --apple-id "$APPLE_ID" \ |
| 141 | + --team-id "$APPLE_TEAM_ID" \ |
| 142 | + --password "$APPLE_APP_PASSWORD" |
| 143 | + |
| 144 | +# Staple notarization ticket and create release zip |
| 145 | +staple: |
| 146 | + #!/usr/bin/env bash |
| 147 | + set -e |
| 148 | + |
| 149 | + if [[ ! -d "{{app_path}}" ]]; then |
| 150 | + echo "Error: App not found at {{app_path}}" |
| 151 | + exit 1 |
| 152 | + fi |
| 153 | + |
| 154 | + echo "Stapling ticket..." |
| 155 | + xcrun stapler staple "{{app_path}}" |
| 156 | + |
| 157 | + echo "Creating release zip..." |
| 158 | + rm -f "{{zip_path}}" |
| 159 | + ditto -c -k --keepParent "{{app_path}}" "{{zip_path}}" |
| 160 | + |
| 161 | + echo "✓ Release ready: {{zip_path}}" |
| 162 | + |
| 163 | +# Full release: archive, submit, wait, staple |
| 164 | +release: _check-env archive |
| 165 | + #!/usr/bin/env bash |
| 166 | + set -e |
| 167 | + |
| 168 | + echo "Creating zip..." |
| 169 | + ditto -c -k --keepParent "{{app_path}}" "{{zip_path}}" |
| 170 | + |
| 171 | + echo "Submitting for notarization..." |
| 172 | + xcrun notarytool submit "{{zip_path}}" \ |
| 173 | + --apple-id "$APPLE_ID" \ |
| 174 | + --team-id "$APPLE_TEAM_ID" \ |
| 175 | + --password "$APPLE_APP_PASSWORD" \ |
| 176 | + --wait |
| 177 | + |
| 178 | + just staple |
| 179 | + echo "✓ Release complete!" |
| 180 | + |
| 181 | +# Show notarization history |
| 182 | +history: _check-env |
| 183 | + xcrun notarytool history \ |
| 184 | + --apple-id "$APPLE_ID" \ |
| 185 | + --team-id "$APPLE_TEAM_ID" \ |
| 186 | + --password "$APPLE_APP_PASSWORD" |
| 187 | + |
| 188 | +# Get notarization log for a submission |
| 189 | +log id: _check-env |
| 190 | + xcrun notarytool log "{{id}}" \ |
| 191 | + --apple-id "$APPLE_ID" \ |
| 192 | + --team-id "$APPLE_TEAM_ID" \ |
| 193 | + --password "$APPLE_APP_PASSWORD" |
| 194 | + |
| 195 | +# ============================================================================= |
| 196 | +# Helpers |
| 197 | +# ============================================================================= |
| 198 | + |
| 199 | +# Verify required environment variables |
| 200 | +[private] |
| 201 | +_check-env: |
| 202 | + #!/usr/bin/env bash |
| 203 | + missing=0 |
| 204 | + for var in APPLE_ID APPLE_TEAM_ID APPLE_APP_PASSWORD; do |
| 205 | + if [[ -z "${!var}" ]]; then |
| 206 | + echo "Missing: $var" |
| 207 | + missing=1 |
| 208 | + fi |
| 209 | + done |
| 210 | + if [[ $missing -eq 1 ]]; then |
| 211 | + echo "" |
| 212 | + echo "Set these in .env or export them:" |
| 213 | + echo " APPLE_ID=your@email.com" |
| 214 | + echo " APPLE_TEAM_ID=XXXXXXXXXX" |
| 215 | + echo " APPLE_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx" |
| 216 | + exit 1 |
| 217 | + fi |
0 commit comments