fix: fetch remote messages on main queue (#795) #284
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, v2] # 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: | |
deploy-git-tag: | |
name: Deploy git tag | |
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. | |
# 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 | |
@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-13 | |
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 CustomerIOTracking | |
run: ./scripts/push-cocoapod.sh CustomerIOTracking.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 |