docs: sample apps readme (#422) #154
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 | |
# Only run after a pull request has been merged. This is because | |
# bot account runs write operations on the github repo to push a tag. | |
on: | |
push: | |
branches: [beta, main] # 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 | |
issues: write # Bot creates an issue if there is an issue during deployment process | |
pull-requests: write # allow bot to make comments on PRs after they get deployed | |
jobs: | |
deploy-git-tag: | |
name: Deploy git tag | |
runs-on: ubuntu-latest | |
outputs: | |
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 | |
# 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. | |
# Setup Android SDK as it's needed to generate the SDK size report. | |
- name: Setup Android SDK | |
uses: ./.github/actions/setup-android | |
# Generate SDK size report to update in main branch before deploying new release. | |
# The report is pushed by semantic-release action below by including files listed in the | |
# `assets` array in the `.releaserc` file. | |
- name: Generate SDK Size Report | |
run: | | |
./gradlew publishToMavenLocal | |
./gradlew generateSdkSizeReport -PwriteReportTo=reports/sdk-binary-size.json | |
env: | |
# Use local version to make sure the report is generated for the current changes | |
IS_DEVELOPMENT: 'true' | |
# 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: | |
dry_run: false | |
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": "Android SDK git tag created", | |
"username": "Android deployment bot", | |
"icon_url": "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg", | |
"channel": "#mobile-deployments", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*Android* SDK git tag created successfully! (deployment step 1 of 2)" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*Version ${{ steps.semantic-release.outputs.new_release_version }}*\nAndroid SDK deployment progress:\n ~1. <https://github.com/${{github.repository}}/releases/tag/${{steps.semantic-release.outputs.new_release_version}}|create git tag>~\n2. deploy to maven central\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": "Android SDK deployment failure", | |
"username": "Android deployment bot", | |
"icon_url": "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg", | |
"channel": "#mobile-deployments", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*Android* SDK deployment :warning: failure :warning:" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Android 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-sonatype: | |
name: Deploy SDK to Maven Central | |
needs: [deploy-git-tag] | |
if: needs.deploy-git-tag.outputs.new_release_published == 'true' # only run if a git tag was made. | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout git tag that got created in previous step | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.deploy-git-tag.outputs.new_release_version }} | |
- uses: ./.github/actions/setup-android | |
- name: Push to Sonatype servers | |
run: MODULE_VERSION=${{ needs.deploy-git-tag.outputs.new_release_version }} ./scripts/deploy-code.sh | |
env: | |
OSSRH_USERNAME: ${{ secrets.GRADLE_PUBLISH_USERNAME }} | |
OSSRH_PASSWORD: ${{ secrets.GRADLE_PUBLISH_PASSWORD }} | |
SIGNING_KEY_ID: ${{ secrets.GRADLE_SIGNING_KEYID }} | |
SIGNING_PASSWORD: ${{ secrets.GRADLE_SIGNING_PASSPHRASE }} | |
SIGNING_KEY: ${{ secrets.GRADLE_SIGNING_PRIVATE_KEY }} | |
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} | |
- 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": "Android SDK deployed to Maven Central", | |
"username": "Android deployment bot", | |
"icon_url": "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg", | |
"channel": "#mobile-deployments", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*Android* SDK deployed to Maven Central! (deployment step 2 of 2)" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*Version ${{ needs.deploy-git-tag.outputs.new_release_version }}*\n\nAndroid SDK deployment progress:\n ~1. <https://github.com/${{github.repository}}/releases/tag/${{ needs.deploy-git-tag.outputs.new_release_version }}|create git tag>~\n~2. deploy to maven central~\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: 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": "Android SDK deployment failure", | |
"username": "Android deployment bot", | |
"icon_url": "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg", | |
"channel": "#mobile-deployments", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*Android* SDK deployment :warning: failure :warning:" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Android SDK failed deployment during step *deploy to maven central*. 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 |