-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
newRelease
executable file
·160 lines (133 loc) · 4.04 KB
/
newRelease
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
set -euo pipefail
# set -x
function help # MSG
{
cat << EOT
usage: newRelease [--macos][--ios] major | minor | patch | build
Update version attributes for the project then build, test, archive, and upload
new payloads to App Store. THis is done for both iOS and macOS builds by default
but can be limited to just one via --macos or --ios.
Note that the build version is always updated to be the current date/time in
YYYYMMDDhhmm format.
major - increment the major version number (and set minor and patch to 0)
minor - increment the minor version number (and set patch to 0)
patch - increment the patch version number
build - only increment the build number, leaving major, minor, and patch as-is.
EOT
}
function log #
{
echo "-- ${@}"
}
function error #
{
echo "** ${@}"
help
exit 1
}
CMD=""
PLATFORMS="macos ios"
while [[ "$#" -gt 0 ]]; do
case "${1}" in
"--macos") PLATFORMS="macos" ;;
"--ios") PLATFORMS="ios" ;;
"major") CMD="major"; ./bumpVersions -d "${PWD}" -1 ;;
"minor") CMD="minor"; ./bumpVersions -d "${PWD}" -2 ;;
"patch") CMD="patch"; ./bumpVersions -d "${PWD}" -3 ;;
"build") CMD="build"; ./bumpVersions -d "${PWD}" -b ;;
*) error "invalid arg - ${1}" ;;
esac
shift 1
done
[[ -z "${CMD}" ]] && error "missing one of 'major', 'minor', 'patch', or 'build'"
# set -- *.xcodeproj
PROJECT="SoundFontsApp/SoundFontsApp.xcodeproj"
log "using PROJECT='${PROJECT}'"
VERSION="$(< .version)"
[[ -z "${VERSION}" ]] && error "failed to get VERSION"
log "using VERSION='${VERSION}'"
if [[ ! -f "${PWD}/exportOptions.plist" ]]; then
set -- $(grep 'DEVELOPMENT_TEAM' "${PWD}/Configuration/Common.xcconfig")
DEVELOPMENT_TEAM="${3}"
log "using DEVELOPMENT_TEAM='${DEVELOPMENT_TEAM}'"
log "creating ${PWD}/exportOptions.plist"
cat << EOT > "${PWD}/exportOptions.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>${DEVELOPMENT_TEAM}</string>
<key>destination</key>
<string>upload</string>
<key>signingStyle</key>
<string>automatic</string>
<key>uploadBitcode</key>
<true/>
<key>uploadSymbols</key>
<true/>
</dict>
</plist>
EOT
fi
function buildTestDeploy # SCHEME DESTINATION
{
local SCHEME="${1}"
local DESTINATION="${2}"
local DATE=$(date +'%Y-%m-%d')
local HHMM=$(date +'%H.%M')
local ARCHIVE_DIR="${HOME}/Library/Developer/Xcode/Archives/${DATE}"
local ARCHIVE="${ARCHIVE_DIR}/${SCHEME} ${DATE},${HHMM}.xcarchive"
mkdir -p "${ARCHIVE_DIR}"
# Compile and test
log "running tests"
xcodebuild \
-project "${PROJECT}" \
-scheme "${SCHEME}" \
-destination "${DESTINATION}" \
test
log "building release"
xcodebuild \
-project "${PROJECT}" \
-scheme "${SCHEME}" \
-destination "${DESTINATION}" \
-configuration Release \
build
[[ -f "${ARCHIVE}" ]] && rm -f "${ARCHIVE}"
log "generating archive"
xcodebuild \
-project "${PROJECT}" \
-scheme "${SCHEME}" \
-destination "${DESTINATION}" \
-configuration Release \
archive \
-archivePath "${ARCHIVE}"
xcodebuild \
-archivePath "${ARCHIVE}" \
-exportArchive \
-exportPath "${PWD}" \
-exportOptionsPlist exportOptions.plist
}
for EACH in ${PLATFORMS}; do
case "${EACH}" in
"ios") buildTestDeploy 'iOS App' 'platform=iOS Simulator,name=iPhone SE (2nd generation)' ;;
"macos") buildTestDeploy 'macOS App' 'platform=macOS' ;;
esac
done
git status
# log "committing version changes"
# git add -u
# git commit -m "v${VERSION}"
# if [[ "${CMD}" != "build" ]]; then
# log "tagging repo with ${VERSION}"
# git tag "${VERSION}"
# fi
# log "pushing changes to remote"
# echo git push
# if [[ "${CMD}" != "build" ]]; then
# log "pushing updated tags to remote"
# git push --tags
# fi