11#! /usr/bin/env bash
2+ set -euo pipefail
23
3- set -euxo pipefail
4+ # Build Documentation @ https://developer.apple.com/forums/thread/737894
5+ APPLE_TEAM_ID=" 4399GN35BJ"
6+ CODE_SIGN_IDENTITY=" Developer ID Application: Coder Technologies Inc (${APPLE_TEAM_ID} )"
47
5- get_uuid () {
6- strings " $1 " | grep -E -o ' [0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}'
8+ # Default values pulled in from env
9+ APP_PROF_PATH=${APP_PROF_PATH:- " " }
10+ EXT_PROF_PATH=${EXT_PROF_PATH:- " " }
11+ KEYCHAIN_PATH=${KEYCHAIN_PATH:- " " }
12+
13+ # Function to display usage
14+ usage () {
15+ echo " Usage: $0 [--app-prof-path <path>] [--ext-prof-path <path>] [--keychain-path <path>]"
16+ echo " --app-prof-path <path> Set the APP_PROF_PATH variable"
17+ echo " --ext-prof-path <path> Set the EXT_PROF_PATH variable"
18+ echo " --keychain-path <path> Set the KEYCHAIN_PATH variable"
19+ echo " -h, --help Display this help message"
720}
821
9- # Build Documentation @ https://developer.apple.com/forums/thread/737894
22+ # Parse command line arguments
23+ while [[ " $# " -gt 0 ]]; do
24+ case $1 in
25+ --app-prof-path)
26+ APP_PROF_PATH=" $2 "
27+ shift 2
28+ ;;
29+ --ext-prof-path)
30+ EXT_PROF_PATH=" $2 "
31+ shift 2
32+ ;;
33+ --keychain-path)
34+ KEYCHAIN_PATH=" $2 "
35+ shift 2
36+ ;;
37+ -h | --help)
38+ usage
39+ exit 0
40+ ;;
41+ * )
42+ echo " Unknown parameter passed: $1 "
43+ usage
44+ exit 1
45+ ;;
46+ esac
47+ done
48+
49+ # Check if required variables are set
50+ if [[ -z " $APP_PROF_PATH " || -z " $EXT_PROF_PATH " || -z " $KEYCHAIN_PATH " ]]; then
51+ echo " Missing required values"
52+ echo
53+ usage
54+ exit 1
55+ fi
1056
1157XCODE_PROVISIONING_PROFILES_DIR=" $HOME /Library/Developer/Xcode/UserData/Provisioning Profiles"
1258ALT_PROVISIONING_PROFILES_DIR=" $HOME /Library/MobileDevice/Provisioning Profiles"
1359mkdir -p " $XCODE_PROVISIONING_PROFILES_DIR "
1460mkdir -p " $ALT_PROVISIONING_PROFILES_DIR "
15- APPLE_TEAM_ID=" 4399GN35BJ"
16- CODE_SIGN_IDENTITY=" Developer ID Application: Coder Technologies Inc (${APPLE_TEAM_ID} )"
61+
62+ get_uuid () {
63+ strings " $1 " | grep -E -o ' [0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}'
64+ }
1765
1866# Extract the ID of each provisioning profile
1967APP_PROVISIONING_PROFILE_ID=$( get_uuid " $APP_PROF_PATH " )
@@ -29,41 +77,43 @@ cp "$EXT_PROF_PATH" "${ALT_PROVISIONING_PROFILES_DIR}/${EXT_PROVISIONING_PROFILE
2977export APP_PROVISIONING_PROFILE_ID
3078export EXT_PROVISIONING_PROFILE_ID
3179export PTP_SUFFIX
80+
3281make
82+
3383xcodebuild \
34- -project " Coder Desktop/Coder Desktop.xcodeproj" \
35- -scheme " Coder Desktop" \
36- -configuration " Release" \
37- -skipPackagePluginValidation \
38- CODE_SIGN_STYLE=Manual \
39- CODE_SIGN_IDENTITY=" $CODE_SIGN_IDENTITY " \
40- CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO \
41- OTHER_CODE_SIGN_FLAGS=' --timestamp' | LC_ALL=" en_US.UTF-8" xcpretty
84+ -project " Coder Desktop/Coder Desktop.xcodeproj" \
85+ -scheme " Coder Desktop" \
86+ -configuration " Release" \
87+ -skipPackagePluginValidation \
88+ CODE_SIGN_STYLE=Manual \
89+ CODE_SIGN_IDENTITY=" $CODE_SIGN_IDENTITY " \
90+ CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO \
91+ OTHER_CODE_SIGN_FLAGS=' --timestamp' | LC_ALL=" en_US.UTF-8" xcpretty
4292
4393mkdir build
4494built_app_path=" ./Coder Desktop.app"
4595ditto " $( find " $HOME /Library/Developer/Xcode/DerivedData" -name " Coder Desktop.app" ) " " $built_app_path "
4696
4797create-dmg \
48- --identity=" $CODE_SIGN_IDENTITY " \
49- " $built_app_path " \
50- ./
98+ --identity=" $CODE_SIGN_IDENTITY " \
99+ " $built_app_path " \
100+ ./
51101
52102# Add dmg to build artifacts
53103dmg_path=" ./build/Coder Desktop.dmg"
54104mv ./Coder\ Desktop* .dmg " $dmg_path "
55105
56106# Notarize
57107xcrun notarytool store-credentials " notarytool-credentials" \
58- --apple-id " $APPLE_ID " \
59- --team-id " $APPLE_TEAM_ID " \
60- --password " $APPLE_ID_PASSWORD " \
61- --keychain " $KEYCHAIN_PATH "
108+ --apple-id " $APPLE_ID " \
109+ --team-id " $APPLE_TEAM_ID " \
110+ --password " $APPLE_ID_PASSWORD " \
111+ --keychain " $KEYCHAIN_PATH "
62112
63113xcrun notarytool submit " $dmg_path " \
64- --keychain-profile " notarytool-credentials" \
65- --keychain " $KEYCHAIN_PATH " \
66- --wait
114+ --keychain-profile " notarytool-credentials" \
115+ --keychain " $KEYCHAIN_PATH " \
116+ --wait
67117
68118# Staple the notarization to the app and dmg, so they work without internet
69119xcrun stapler staple " $dmg_path "
0 commit comments