-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodemagic.yaml
More file actions
235 lines (216 loc) · 8.7 KB
/
codemagic.yaml
File metadata and controls
235 lines (216 loc) · 8.7 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
workflows:
ios-unsigned-workflow:
name: iOS Unsigned Build
max_build_duration: 60
instance_type: mac_mini_m1
environment:
groups:
- discord_credentials
vars:
XCODE_WORKSPACE: "FrameExtractionTool.xcodeproj"
XCODE_SCHEME: "FrameExtractionTool"
BUNDLE_ID: "caspernyong.FrameExtractionTool.CMTest"
xcode: edge
cocoapods: default
scripts:
- name: Get CocoaPods sources
script: |
if [ -f "Podfile" ]; then
pod install
else
echo "No Podfile found, skipping CocoaPods installation"
fi
- name: Build unsigned archive
script: |
set -e
xcodebuild \
-project "$XCODE_WORKSPACE" \
-scheme "$XCODE_SCHEME" \
-configuration Release \
-destination "generic/platform=iOS" \
-archivePath "build/FrameExtractionTool.xcarchive" \
archive \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGN_IDENTITY="" \
PROVISIONING_PROFILE="" \
DEVELOPMENT_TEAM="" \
PRODUCT_BUNDLE_IDENTIFIER="$BUNDLE_ID"
- name: Create unsigned IPA
script: |
set -e
mkdir -p build/Payload
cp -r "build/FrameExtractionTool.xcarchive/Products/Applications/FrameExtractionTool.app" "build/Payload/"
cd build
zip -r "FrameExtractionTool-unsigned.ipa" "Payload/"
ls -la FrameExtractionTool-unsigned.ipa
- name: Verify IPA structure
script: |
cd build
unzip -l FrameExtractionTool-unsigned.ipa | head -20
- name: Create changelog
script: |
if [[ -z ${CM_PREVIOUS_COMMIT} ]]; then
echo "No previous builds found to generate changelog" | tee release_notes.txt
else
echo "$(git log --oneline $CM_PREVIOUS_COMMIT..$CM_COMMIT)" | tee release_notes.txt
fi
artifacts:
- build/FrameExtractionTool-unsigned.ipa
- build/FrameExtractionTool.xcarchive
- /tmp/xcodebuild_logs/*.log
publishing:
scripts:
- name: Discord notification
script: |
set -ex
# Check if WEBHOOK_URL is set
if [ -z "$WEBHOOK_URL" ]; then
echo "Warning: WEBHOOK_URL is not set. Skipping Discord notification."
echo "Please set the WEBHOOK_URL environment variable in the discord_credentials group."
exit 0
fi
# Get artifact link for the IPA file
APP_LINK=$(echo $CM_ARTIFACT_LINKS | jq -r '.[] | select(.name | contains("FrameExtractionTool-unsigned.ipa")) | .url // "No artifact link available"')
# Get first 7 digits of commit number
COMMIT=$(echo "${CM_COMMIT}" | sed 's/^\(........\).*/\1/;q')
# Get commit message (escape quotes and newlines for JSON)
COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT | tr '\n' ' ' | sed 's/"/\\"/g')
# Get commit author
AUTHOR=$(git show -s --format='%ae' $CM_COMMIT)
# Get build status
BUILD_STATUS="✅ Build Successful"
# Create the JSON payload
PAYLOAD=$(cat <<EOF
{
"username": "FrameExtractionTool-CI",
"content": "$BUILD_STATUS - iOS Unsigned Build\\n\\n**Commit:** \`$COMMIT\`\\n\\n**Commit message:** $COMMIT_MESSAGE\\n\\n**Branch:** $CM_BRANCH\\n\\n**Author:** $AUTHOR\\n\\n**Build:** $CM_BUILD_URL\\n\\n**Artifacts:**\\n$APP_LINK"
}
EOF
)
# Send Discord notification
if [ -f "release_notes.txt" ]; then
curl -H "Content-Type: multipart/form-data" \
-F "payload_json=$PAYLOAD" \
-F "file1=@release_notes.txt" \
"$WEBHOOK_URL"
else
curl -H "Content-Type: application/json" \
-d "$PAYLOAD" \
"$WEBHOOK_URL"
fi
ios-release-workflow:
name: iOS Release Build
max_build_duration: 60
instance_type: mac_mini_m1
triggering:
events:
- tag
tag_patterns:
- pattern: 'v*'
include: true
environment:
groups:
- discord_credentials
vars:
XCODE_WORKSPACE: "FrameExtractionTool.xcodeproj"
XCODE_SCHEME: "FrameExtractionTool"
BUNDLE_ID: "caspernyong.FrameExtractionTool.CMTest"
xcode: latest
cocoapods: default
scripts:
- name: Get CocoaPods sources
script: |
if [ -f "Podfile" ]; then
pod install
else
echo "No Podfile found, skipping CocoaPods installation"
fi
- name: Build unsigned archive for release
script: |
set -e
# Get version from git tag
VERSION=${CM_TAG#v}
echo "Building release version: $VERSION"
xcodebuild \
-project "$XCODE_WORKSPACE" \
-scheme "$XCODE_SCHEME" \
-configuration Release \
-destination "generic/platform=iOS" \
-archivePath "build/FrameExtractionTool-$VERSION.xcarchive" \
archive \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGN_IDENTITY="" \
PROVISIONING_PROFILE="" \
DEVELOPMENT_TEAM="" \
PRODUCT_BUNDLE_IDENTIFIER="$BUNDLE_ID"
- name: Create unsigned release IPA
script: |
set -e
VERSION=${CM_TAG#v}
mkdir -p build/Payload
cp -r "build/FrameExtractionTool-$VERSION.xcarchive/Products/Applications/FrameExtractionTool.app" "build/Payload/"
cd build
zip -r "FrameExtractionTool-$VERSION-unsigned.ipa" "Payload/"
ls -la FrameExtractionTool-$VERSION-unsigned.ipa
- name: Verify release IPA structure
script: |
cd build
VERSION=${CM_TAG#v}
unzip -l "FrameExtractionTool-$VERSION-unsigned.ipa" | head -20
- name: Create release changelog
script: |
if [[ -z ${CM_PREVIOUS_COMMIT} ]]; then
echo "Release $CM_TAG" | tee release_notes.txt
echo "No previous builds found to generate changelog" >> release_notes.txt
else
echo "Release $CM_TAG" | tee release_notes.txt
echo "$(git log --oneline $CM_PREVIOUS_COMMIT..$CM_COMMIT)" >> release_notes.txt
fi
artifacts:
- build/FrameExtractionTool-*-unsigned.ipa
- build/FrameExtractionTool-*.xcarchive
- /tmp/xcodebuild_logs/*.log
publishing:
scripts:
- name: Discord release notification
script: |
set -ex
# Check if WEBHOOK_URL is set
if [ -z "$WEBHOOK_URL" ]; then
echo "Warning: WEBHOOK_URL is not set. Skipping Discord notification."
echo "Please set the WEBHOOK_URL environment variable in the discord_credentials group."
exit 0
fi
# Get version from tag
VERSION=${CM_TAG#v}
# Get artifact link for the release IPA file
APP_LINK=$(echo $CM_ARTIFACT_LINKS | jq -r '.[] | select(.name | contains("FrameExtractionTool-") and contains("-unsigned.ipa")) | .url // "No artifact link available"')
# Get first 7 digits of commit number
COMMIT=$(echo "${CM_COMMIT}" | sed 's/^\(........\).*/\1/;q')
# Get commit message (escape quotes and newlines for JSON)
COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT | tr '\n' ' ' | sed 's/"/\\"/g')
# Get commit author
AUTHOR=$(git show -s --format='%ae' $CM_COMMIT)
# Get build status
BUILD_STATUS="🚀 Release Build Successful"
# Create the JSON payload
PAYLOAD=$(cat <<EOF
{
"username": "FrameExtractionTool-CI",
"content": "$BUILD_STATUS - iOS Release v$VERSION\\n\\n**Release Tag:** \`$CM_TAG\`\\n\\n**Commit:** \`$COMMIT\`\\n\\n**Commit message:** $COMMIT_MESSAGE\\n\\n**Branch:** $CM_BRANCH\\n\\n**Author:** $AUTHOR\\n\\n**Build:** $CM_BUILD_URL\\n\\n**Release Artifacts:**\\n$APP_LINK"
}
EOF
)
# Send Discord notification
if [ -f "release_notes.txt" ]; then
curl -H "Content-Type: multipart/form-data" \
-F "payload_json=$PAYLOAD" \
-F "file1=@release_notes.txt" \
"$WEBHOOK_URL"
else
curl -H "Content-Type: application/json" \
-d "$PAYLOAD" \
"$WEBHOOK_URL"
fi