diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 32e1dd892..4ca0000f0 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -5,10 +5,55 @@ on: branches: [ master ] jobs: - beta_deploy: - name: Beta Deploy + 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: @@ -53,20 +98,6 @@ jobs: CREDS: ${{ secrets.FIREBASECREDS }} run: echo $CREDS > firebaseAppDistributionServiceCredentialsFile.json - - name: Inflate playStorePublishServiceCredentialsFile.json - env: - CREDS: ${{ secrets.PLAYSTORECREDS }} - run: echo $CREDS > app/playStorePublishServiceCredentialsFile.json - - - name: Validate ktlint - run: ./gradlew ktlintCheck - - - name: Validate Lint - run: ./gradlew lint - - - name: Validate Tests - run: ./gradlew test - - name: Build Release env: KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }} @@ -77,7 +108,7 @@ jobs: - 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` + 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 @@ -121,10 +152,72 @@ jobs: 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.ORIGINAL_KEYSTORE_FILE_PASSWORD }} KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }} KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }} run: ./gradlew publishFullReleaseBundle - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c544c0f2d..4a67579bb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,9 +5,55 @@ on: types: [ released ] jobs: - prod_deploy: - name: Production Deploy + 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: @@ -20,15 +66,15 @@ jobs: - name: Set Build Number run: | - VERSION=`git describe --tags` - echo ::set-env name=VERSION::$VERSION 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 @@ -51,20 +97,6 @@ jobs: CREDS: ${{ secrets.FIREBASECREDS }} run: echo $CREDS > firebaseAppDistributionServiceCredentialsFile.json - - name: Inflate playStorePublishServiceCredentialsFile.json - env: - CREDS: ${{ secrets.PLAYSTORECREDS }} - run: echo $CREDS > app/playStorePublishServiceCredentialsFile.json - - - name: Validate ktlint - run: ./gradlew ktlintCheck - - - name: Validate Lint - run: ./gradlew lint - - - name: Validate Tests - run: ./gradlew test - - name: Build Release env: KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }} @@ -81,12 +113,24 @@ jobs: git log --format=%s ${previous}..${current} >> 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: ${{ github.event.release.upload_url }} + 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 @@ -96,7 +140,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ github.event.release.upload_url }} + 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 @@ -108,16 +152,72 @@ jobs: 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)) + 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 + 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.ORIGINAL_KEYSTORE_FILE_PASSWORD }} KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }} KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }} run: ./gradlew publishFullReleaseBundle - - - name: Promote to Beta to Production - env: - KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }} - KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }} - KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }} - run: ./gradlew promoteArtifact --from-track beta --promote-track production