Merge pull request #105 from dolbyio-samples/feature/ms-test-2.0.0 #213
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: CD Android build and distribution | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
env: | |
GIT_USERNAME: "dolbyio-gh-bot" | |
jobs: | |
Android-App-Build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: Cache Gradle Wrapper | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | |
- name: Install the signing certificate | |
env: | |
DISTRIBUTION_CERTIFICATE_ANDROID_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }} | |
run: | | |
CERTIFICATE_PATH=./app/release.keystore | |
echo -n "$DISTRIBUTION_CERTIFICATE_ANDROID_BASE64" | base64 --decode > $CERTIFICATE_PATH | |
- name: calculate version | |
run: | | |
versionName='1.0.'$GITHUB_RUN_NUMBER | |
versionCode=$GITHUB_RUN_NUMBER; echo "versionName: $versionName; versionCode: $versionCode" | |
echo "export VERSION_NAME=$versionName; export VERSION_CODE=$versionCode" > ~/.env_version | |
- name: Android TV App Release Build | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_STORE_PASSWORD }} | |
KEY_ALIAS: ${{ secrets.RELEASE_KEYSTORE_KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_KEY_PASSWORD }} | |
GIT_PAT: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD | |
export KEY_ALIAS=$KEY_ALIAS | |
export KEY_PASSWORD=$KEY_PASSWORD | |
source ~/.env_version | |
chmod +x ./gradlew && ./gradlew app:assembleTvRelease app:bundleTvRelease | |
- name: Archive Viewer production bundle | |
uses: actions/upload-artifact@v3 | |
with: | |
name: android-app-release-bundle | |
path: | | |
./app/build/outputs/bundle/tvRelease/app-tv-release.aab | |
Android-Play-Store-Distribution: | |
needs: Android-App-Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: Cache Gradle Wrapper | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | |
- name: Download release artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: android-app-release-bundle | |
path: ./app/build/outputs/bundle/tvRelease/ | |
- name: Create release notes | |
run: | | |
RELEASE_NOTES_FILE=./app/src/main/play/release-notes/en-US/default.txt | |
mkdir -p "$(dirname $RELEASE_NOTES_FILE)" && touch "$RELEASE_NOTES_FILE" | |
echo "Android TV app update: ${{ github.event.head_commit.message }}" > $RELEASE_NOTES_FILE | |
- name: Deploy TV app to Play Store | |
env: | |
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }} | |
GIT_PAT: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
versionName='1.0.'$GITHUB_RUN_NUMBER | |
versionCode=$GITHUB_RUN_NUMBER | |
export ANDROID_PUBLISHER_CREDENTIALS=$ANDROID_PUBLISHER_CREDENTIALS | |
chmod +x ./gradlew && ./gradlew app:publishTvReleaseBundle --artifact-dir ./app/build/outputs/bundle/tvRelease/ --release-name "$versionCode ($versionName) TV" --stacktrace |