home-assistant-android/.github/workflows/release.yml
2020-09-01 14:57:56 -04:00

228 lines
8 KiB
YAML

name: Production Deploy
on:
release:
types: [ released ]
jobs:
ktlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Mock google-services.json
run: mv .github/mock-google-services.json app/google-services.json
- name: Validate ktlint
run: ./gradlew ktlintCheck
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Mock google-services.json
run: mv .github/mock-google-services.json app/google-services.json
- name: Validate Lint
run: ./gradlew lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Mock google-services.json
run: mv .github/mock-google-services.json app/google-services.json
- name: Validate Tests
run: ./gradlew test
github_publish:
name: Github & Firebase Publish
runs-on: ubuntu-latest
needs: [ ktlint, lint, test ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set Build Number
run: |
COMMITS=`git rev-list --count HEAD`
TAGS=`git tag | wc -l`
VC=$((COMMITS+TAGS))
VERSION=`git describe --tags`
echo Number Commits $COMMITS
echo Number Tags $TAGS
echo Version $VERSION
echo Version Code $VC
echo ::set-env name=VERSION::$VERSION
echo ::set-env name=VERSION_CODE::$VC
- name: Mock debug google-services.json
run: |
cp .github/mock-google-services.json app/src/debug/google-services.json
cp .github/mock-google-services.json app/src/minimal/google-services.json
- name: Inflate release_keystore.keystore
env:
KEYSTORE: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
run: echo $KEYSTORE | base64 --decode > app/release_keystore.keystore
- name: Inflate google-services.json
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLESERVICES }}
run: echo $GOOGLE_SERVICES > app/google-services.json
- name: Inflate firebaseAppDistributionServiceCredentialsFile.json
env:
CREDS: ${{ secrets.FIREBASECREDS }}
run: echo $CREDS > firebaseAppDistributionServiceCredentialsFile.json
- name: Build Release
env:
KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
run: ./gradlew assembleRelease
- name: Create Release Notes
run: |
mkdir -p app/src/main/play/release-notes/en-US/
previous=`git tag -l --sort=-creatordate | grep -v beta- | head -n 2 | tail -n 1`
current=`git tag -l --sort=-creatordate | head -n 1`
echo "Full release change log: https://github.com/home-assistant/android/releases/tag/${current}" > app/src/main/play/release-notes/en-US/default-long.txt
git log --format=%s ${previous}..${current} >> app/src/main/play/release-notes/en-US/default-long.txt
head -n 2 app/src/main/play/release-notes/en-US/default-long.txt > app/src/main/play/release-notes/en-US/default.txt
- name: Get the upload URL for the release
uses: bruceadams/get-release@v1.2.1
id: get_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Full APK
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./app/build/outputs/apk/full/release/app-full-release.apk
asset_name: home-assistant-full-${{env.VERSION}}.apk
asset_content_type: application/zip
- name: Upload Minimal APK
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./app/build/outputs/apk/minimal/release/app-minimal-release.apk
asset_name: home-assistant-minimal-${{env.VERSION}}.apk
asset_content_type: application/zip
- name: Deploy to Firebase
env:
KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
run: ./gradlew appDistributionUploadFullRelease
- name: Create a Sentry.io release
uses: tclindner/sentry-releases-action@v1.2.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
tagName: io.homeassistant.companion.android@${{ env.VERSION }}
environment: Production
play_publish:
name: Play Publish
runs-on: ubuntu-latest
needs: [ ktlint, lint, test ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set Build Number
run: |
COMMITS=`git rev-list --count HEAD`
TAGS=`git tag | wc -l`
VC=$((COMMITS+TAGS))
VERSION=`git describe --tags`
echo Number Commits $COMMITS
echo Number Tags $TAGS
echo Version $VERSION
echo Version Code $VC
echo ::set-env name=VERSION::$VERSION
echo ::set-env name=VERSION_CODE::$VC
- name: Mock debug google-services.json
run: |
cp .github/mock-google-services.json app/src/debug/google-services.json
cp .github/mock-google-services.json app/src/minimal/google-services.json
- name: Inflate release_keystore.keystore
env:
KEYSTORE: ${{ secrets.UPLOAD_KEYSTORE_FILE }}
run: echo $KEYSTORE | base64 --decode > app/release_keystore.keystore
- name: Inflate google-services.json
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLESERVICES }}
run: echo $GOOGLE_SERVICES > app/google-services.json
- name: Inflate playStorePublishServiceCredentialsFile.json
env:
CREDS: ${{ secrets.PLAYSTORECREDS }}
run: echo $CREDS > app/playStorePublishServiceCredentialsFile.json
- name: Build Release
env:
KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_FILE_PASSWORD }}
KEYSTORE_ALIAS: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }}
KEYSTORE_ALIAS_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }}
run: ./gradlew assembleRelease
- name: Create Release Notes
run: |
mkdir -p app/src/main/play/release-notes/en-US/
previous=`git tag -l --sort=-creatordate | grep -v beta- | head -n 2 | tail -n 1`
current=`git tag -l --sort=-creatordate | head -n 1`
echo "Full release change log: https://github.com/home-assistant/android/releases/tag/${current}" > app/src/main/play/release-notes/en-US/default-long.txt
git log --format=%s ${previous}..${current} >> app/src/main/play/release-notes/en-US/default-long.txt
head -n 2 app/src/main/play/release-notes/en-US/default-long.txt > app/src/main/play/release-notes/en-US/default.txt
- name: Deploy to Playstore Beta
env:
KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_FILE_PASSWORD }}
KEYSTORE_ALIAS: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }}
KEYSTORE_ALIAS_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }}
run: ./gradlew publishFullReleaseBundle