-
Notifications
You must be signed in to change notification settings - Fork 22
290 lines (270 loc) · 14.6 KB
/
deploy-sdk.yml
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
name: Deploy SDK
on:
workflow_dispatch: # manually run this workflow. This allows you to manually deploy things like cococapods, not manually create a git tag. The tag needs to already be created to run this.
inputs:
existing-git-tag:
description: 'Type name of existing git tag (example: 1.0.3) to checkout and manually deploy'
required: true
type: string
push:
branches: [beta, main, v1] # all branches where deployments currently occur. Make sure this list matches list of branches in `.releaserc` file.
permissions:
contents: write # access to push the git tag
jobs:
# We can only generate SDK size reports on macOS and we prefer to run deployments on Linux because macOS resources are limited.
# Therefore, generating SDK reports is a separate job that runs before deployment.
generate-sdk-size-report:
name: Generate SDK size report to attach to the release
runs-on: macos-14
# In order to pass data from 1 action to another, you use outputs.
# These are the generated reports that the deployment action depends on.
outputs:
sdk-size-report: ${{ steps.generate-sdk-size-report.outputs.sdk-size-report }}
sdk-size-including-dependencies-report: ${{ steps.generate-sdk-size-report.outputs.sdk-size-including-dependencies-report }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/generate-sdk-size-report
id: generate-sdk-size-report
with:
GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64: ${{ secrets.GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64 }}
deploy-git-tag:
name: Deploy git tag
needs: [generate-sdk-size-report]
runs-on: ubuntu-latest
outputs:
new_release_git_head: ${{ steps.semantic-release.outputs.new_release_git_head }}
new_release_published: ${{ steps.semantic-release.outputs.new_release_published }}
new_release_version: ${{ steps.semantic-release.outputs.new_release_version }}
steps:
- uses: actions/checkout@v4
# CLI to replace strings in files. The CLI recommends using `cargo install` which is slow. This Action is fast because it downloads pre-built binaries.
# If using sd on macos, "brew install" works great. for Linux, this is the recommended way.
- name: Install sd CLI to use later in the workflow
# uses: kenji-miyake/setup-sd@v1
uses: levibostian/setup-sd@add-file-extension # Using fork until upstream Action has bug fixed in it.
# We want to track the SDK binary size for each release.
# The reports is pushed by semantic-release action below by including files listed in the `assets` array in the `.releaserc` file.
- name: Write SDK size reports to file to include in the release
run: |
mkdir -p reports
echo "${{ needs.generate-sdk-size-report.outputs.sdk-size-report }}" > reports/sdk-binary-size.txt
echo "${{ needs.generate-sdk-size-report.outputs.sdk-size-including-dependencies-report }}" > reports/sdk-binary-size-including-dependencies.txt
echo "Verifying the reports got written to the file system. If the files are not empty, they were generated successfully..."
echo "SDK binary size report:"
head reports/sdk-binary-size.txt
echo "SDK binary size including dependencies report:"
head reports/sdk-binary-size-including-dependencies.txt
# Semantic-release tool is used to:
# 1. Determine the next semantic version for the software during deployment.
# For example, if the last deployment you made was version 1.3.5 and you are releasing a new feature
# in this deployment, semantic release will automatically determine the version is 1.4.0 for this new release you're doing.
# Semantic release is able to do this by viewing commit messages since the last release. That's why this project uses a
# specific commit message format during pull requests.
# 2. Updates metadata files. Such as updating the version number in package.json and adding entries to CHANGELOG.md file.
# 3. Create git tag and push it to github.
- name: Deploy git tag via semantic-release
uses: cycjimmy/semantic-release-action@v4
id: semantic-release
with:
# version numbers below can be in many forms: M, M.m, M.m.p
# version should be greater than the 22.0.1 (https://github.com/semantic-release/semantic-release/releases/tag/v22.0.1)
# because previous version had a bug in commit analyzer
semantic_version: latest
extra_plugins: |
conventional-changelog-conventionalcommits@8
@semantic-release/github
@semantic-release/exec
env:
# Needs to push git commits to repo. Needs write access.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify team of git tag being created
uses: slackapi/[email protected]
if: steps.semantic-release.outputs.new_release_published == 'true' # only run if a git tag was made.
with:
# Use block kit for format of the JSON payloads: https://app.slack.com/block-kit-builder
payload: |
{
"text": "iOS SDK git tag created",
"username": "iOS deployment bot",
"icon_url": "https://pngimg.com/uploads/apple_logo/apple_logo_PNG19687.png",
"channel": "#mobile-deployments",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*iOS* SDK git tag created successfully and deployed to Swift Package Manager! (deployment step 1 of 2)"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Version ${{ steps.semantic-release.outputs.new_release_version }}*\niOS SDK deployment progress:\n ~1. <https://github.com/${{github.repository}}/releases/tag/${{steps.semantic-release.outputs.new_release_version}}|create git ta and deploy to Swift Package Manager>~\n2. deploy to cocoapods\n\n"
}
}
]
}
env:
# Incoming webhook URL that sends message into the correct Slack channel.
# Help on how to get the webhook URL: https://github.com/marketplace/actions/slack-send#setup-2
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Send Velocity Deployment
uses: codeclimate/[email protected]
if: steps.semantic-release.outputs.new_release_published == 'true' # only run if a git tag was made.
with:
token: ${{ secrets.VELOCITY_DEPLOYMENT_TOKEN }}
version: ${{ steps.semantic-release.outputs.new_release_version }}
environment: production
- name: Notify team of failure
uses: slackapi/[email protected]
if: ${{ failure() }} # only run this if any previous step failed
with:
# Use block kit for format of the JSON payloads: https://app.slack.com/block-kit-builder
payload: |
{
"text": "iOS SDK deployment failure",
"username": "iOS deployment bot",
"icon_url": "https://pngimg.com/uploads/apple_logo/apple_logo_PNG19687.png",
"channel": "#mobile-deployments",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*iOS* SDK deployment :warning: failure :warning:"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "iOS SDK failed deployment during step *create git tag*. View <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|CI server logs> to learn why and fix the issue. <https://github.com/customerio/mobile/blob/main/GIT-WORKFLOW.md|Learn more about the deployment process and how to fix errors>."
}
}
]
}
env:
# Incoming webhook URL that sends message into the correct Slack channel.
# Help on how to get the webhook URL: https://github.com/marketplace/actions/slack-send#setup-2
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
deploy-cocoapods:
name: Deploy SDK to Cocoapods
needs: [deploy-git-tag] # run after git tag is made
# Only run if we can find a git tag to checkout.
if: ${{ needs.deploy-git-tag.outputs.new_release_published == 'true' || github.event_name == 'workflow_dispatch' }}
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
runs-on: macos-14
steps:
- name: Checkout git tag that got created in previous step
uses: actions/checkout@v4
if: ${{ needs.deploy-git-tag.outputs.new_release_published == 'true' }}
with:
ref: ${{ needs.deploy-git-tag.outputs.new_release_git_head }}
- name: Checkout git tag that was previously created
uses: actions/checkout@v4
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
ref: ${{ inputs.existing-git-tag }}
- uses: ./.github/actions/setup-ios
- name: Install cocoapods
run: gem install cocoapods
- name: '⚠️ Note: Pushing to cocoapods is flaky. If you see some errors in these logs while deploying, re-run this GitHub Action to try deployment again and it might fix the issue.'
run: echo ''
- name: Push CustomerIOCommon
run: ./scripts/push-cocoapod.sh CustomerIOCommon.podspec
- name: Push CustomerIOTrackingMigration
run: ./scripts/push-cocoapod.sh CustomerIOTrackingMigration.podspec
- name: Push CustomerIODataPipelines
run: ./scripts/push-cocoapod.sh CustomerIODataPipelines.podspec
- name: Push CustomerIOMessagingPush
run: ./scripts/push-cocoapod.sh CustomerIOMessagingPush.podspec
- name: Push CustomerIOMessagingPushAPN
run: ./scripts/push-cocoapod.sh CustomerIOMessagingPushAPN.podspec
- name: Push CustomerIOMessagingPushFCM
run: ./scripts/push-cocoapod.sh CustomerIOMessagingPushFCM.podspec
- name: Push CustomerIOMessagingInApp
run: ./scripts/push-cocoapod.sh CustomerIOMessagingInApp.podspec
- name: Push CustomerIO
run: ./scripts/push-cocoapod.sh CustomerIO.podspec
- name: Notify team of successful deployment
uses: slackapi/[email protected]
if: ${{ success() }}
with:
# Use block kit for format of the JSON payloads: https://app.slack.com/block-kit-builder
payload: |
{
"text": "iOS SDK deployed to CocoaPods",
"username": "iOS deployment bot",
"icon_url": "https://pngimg.com/uploads/apple_logo/apple_logo_PNG19687.png",
"channel": "#mobile-deployments",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*iOS* SDK deployed to Cocoapods! (deployment step 2 of 2)"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Version ${{ github.event.release.tag_name }}*\n\niOS SDK deployment progress:\n ~1. <https://github.com/${{github.repository}}/releases/tag/${{ github.event.release.tag_name }}|create git tag and deploy to Swift Package Manager>~\n~2. deploy to cocoapods~\n\nBecause it's hard to automatically verify cocoapods get deployed, it's recommended to manually verify if cocoapods got deployed successfully by checking for cococapods emails or https://github.com/cocoaPods/specs to see if new commit was added for the release."
}
}
]
}
env:
# Incoming webhook URL that sends message into the correct Slack channel.
# Help on how to get the webhook URL: https://github.com/marketplace/actions/slack-send#setup-2
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Notify team of failure
uses: slackapi/[email protected]
if: ${{ failure() }} # only run this if any previous step failed
with:
# Use block kit for format of the JSON payloads: https://app.slack.com/block-kit-builder
payload: |
{
"text": "iOS SDK deployment failure",
"username": "iOS deployment bot",
"icon_url": "https://pngimg.com/uploads/apple_logo/apple_logo_PNG19687.png",
"channel": "#mobile-deployments",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*iOS* SDK deployment :warning: failure :warning:"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "iOS SDK failed deployment during step *deploy to cocoapods*. View <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|CI server logs> to learn why and fix the issue. <https://github.com/customerio/mobile/blob/main/GIT-WORKFLOW.md|Learn more about the deployment process and how to fix errors>."
}
}
]
}
env:
# Incoming webhook URL that sends message into the correct Slack channel.
# Help on how to get the webhook URL: https://github.com/marketplace/actions/slack-send#setup-2
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK