Skip to content

.github/workflows/build.yml #147

.github/workflows/build.yml

.github/workflows/build.yml #147

Workflow file for this run

# build
on:
workflow_dispatch:
inputs:
repository:
default: viamrobotics/rdk
ref:
default: main
schedule:
- cron: '0 15 * * 1-5'
jobs:
daily:
runs-on: buildjet-8vcpu-ubuntu-2204
container: ghcr.io/${{ github.repository }}
steps:
- name: sentry begin
run: curl ${{ secrets.SENTRY_CRONS }}?status=in_progress
- uses: actions/checkout@v4
with:
path: rdk-apk
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository || 'viamrobotics/rdk' }}
ref: ${{ inputs.ref }}
path: rdk
- name: extract keystore
# we do this so CI builds have consistent signing. otherwise you cannot `adb install` without uninstalling first
env:
DEBUG_KEYSTORE: ${{ secrets.DEBUG_KEYSTORE }}
run: |
mkdir -p ~/.android
[ -n "$DEBUG_KEYSTORE" ] && echo "$DEBUG_KEYSTORE" | base64 > ~/.android/debug.keystore
# todo: put x264 in same etc/android/prefix, then try pkgconfig
# todo: look at short-lived cache of etc/android/prefix
- name: build x264
if: hashFiles('rdk/etc/android/build-x264.sh') != ''
working-directory: rdk
run: |
make etc/android/prefix/aarch64
make etc/android/prefix/x86_64
- name: build AAR
working-directory: rdk
run: PLATFORM_NDK_ROOT=$NDK_ROOT NDK_ROOT=$NDK_ROOT make droid-rdk.aar
# todo: pass down APK + RDK version information
- name: build APKs
working-directory: rdk-apk
shell: bash
run: |
mkdir ../dist
source $SDKMAN_DIR/bin/sdkman-init.sh
export APK_VERSION_SUFFIX=-$(date +%y%m%d)-$(cd ../rdk && git rev-parse --short HEAD)-$(git rev-parse --short HEAD)
# todo(review): is it safe to use gradle in path instead of gradlew? or way to make gradlew use system gradle?
RDK_PATH=$(realpath ../rdk/droid-rdk.arm64.aar) gradle --no-daemon assembleDebug
mv app/build/outputs/apk/debug/app-debug.apk \
../dist/rdk$APK_VERSION_SUFFIX.aarch64.apk
RDK_PATH=$(realpath ../rdk/droid-rdk.amd64.aar) gradle --no-daemon assembleDebug
mv app/build/outputs/apk/debug/app-debug.apk \
../dist/rdk$APK_VERSION_SUFFIX.x86_64.apk
- uses: actions/upload-artifact@v4
with:
name: Arm APK
path: dist/*.aarch64.apk
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: x86 APK
path: dist/*.x86_64.apk
if-no-files-found: error
# next few steps only run on event_name == 'schedule'
- name: rename to latest
if: github.event_name == 'schedule'
working-directory: dist
shell: bash
run: |
for arch in aarch64 x86_64; do
mv *.$arch.apk rdk-apk-latest.$arch.apk
done
- uses: google-github-actions/auth@v2
if: github.event_name == 'schedule'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- uses: google-github-actions/upload-cloud-storage@v2
if: github.event_name == 'schedule'
with:
headers: "cache-control: no-cache"
path: dist/
glob: rdk-apk-latest.*.apk
destination: packages.viam.com/apps/rdk-apk
parent: false
- name: sentry ok
if: success()
run: curl ${{ secrets.SENTRY_CRONS }}?status=ok
- name: sentry error
if: failure()
run: curl ${{ secrets.SENTRY_CRONS }}?status=error
# todo: get a working token and re-enable this
# - uses: slackapi/slack-github-action@v1
# # todo: switch to slack integration when https://github.com/integrations/slack/issues/1563 is resolved (only report errors)
# if: github.event_name == 'schedule' && failure()
# with:
# payload: |
# {
# "text": "android daily build failed",
# "blocks": [
# {
# "type": "section",
# "text": {
# "type": "mrkdwn",
# "text": "${{ github.workflow }} [run ${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
# }
# }
# ]
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}