name: Beta Deploy on: push: branches: [ master ] 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)) HASH=`git rev-parse --short HEAD` VERSION=beta-$VC-$HASH 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 1` echo "Full release notes: https://github.com/home-assistant/android/releases/tag/$VERSION" >> app/src/main/play/release-notes/en-US/default-long.txt git log --format=%s ${previous}..HEAD >> app/src/main/play/release-notes/en-US/default-long.txt cut -c 1-500 app/src/main/play/release-notes/en-US/default-long.txt > app/src/main/play/release-notes/en-US/default.txt - name: Create Github Pre-Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ env.VERSION }} release_name: ${{ env.VERSION }} body_path: ./app/src/main/play/release-notes/en-US/default-long.txt draft: false prerelease: true - name: Upload Full APK uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_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.create_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 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)) HASH=`git rev-parse --short HEAD` VERSION=beta-$VC-$HASH 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 1` echo "Full release notes: https://github.com/home-assistant/android/releases/tag/$VERSION" >> app/src/main/play/release-notes/en-US/default-long.txt git log --format=%s ${previous}..HEAD >> app/src/main/play/release-notes/en-US/default-long.txt cut -c 1-500 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