Skip to content

Android Build Release Workflow #22

Android Build Release Workflow

Android Build Release Workflow #22

Workflow file for this run

name: Android Build Release Workflow
on:
push:
#branches: [ dev ]
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
- name: create and checkout branch
# push events already checked out the branch
if: github.event_name == 'pull_request'
run: git checkout -B ${{ github.head_ref }}
#- name: restoreReleaseKeystore
# run: |
# echo "${{ secrets.RELEASE_KEYSTORE }}" -d -o release.keystore release.keystore.asc
# gpg --batch --passphrase "${{ secrets.RELEASE_KEYSTORE_GPG }}" -d -o release.keystore release.keystore.asc
- name: generate ChangeLog
run: |
git show --no-patch HEAD --format='%B' > customChangeLogFile
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: "temurin"
- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Rename strings from NewPipe to BraveNewPipe
run: ./gradlew bravify
- name: Build brave flavor
run: ./gradlew assembleBraveRelease
- name: Build braveConscrypt flavor
run: ./gradlew assembleBraveConscryptRelease
- name: Prepare for building braveLegacy flavor
run: ./gradlew prepareLegacyFlavor
- name: Build braveLegacy flavor
run: ./gradlew assembleBraveLegacyRelease
- name: Setup build tool version variable
shell: bash
run: |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
echo Last build tool version is: $BUILD_TOOL_VERSION
- name: Sign app APK brave
uses: r0adkll/sign-android-release@v1
# ID used to access action output
id: sign_app
with:
releaseDirectory: app/build/outputs/apk/brave/release
signingKeyBase64: ${{ secrets.RELEASE_KEYSTORE }}
#alias: ${{ secrets.ALIAS }}
alias: alias_name
keyStorePassword: ${{ secrets.RELEASE_KEYSTORE_PASS }}
#keyPassword: ${{ secrets.RELEASE_KEYSTORE_PASS }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
- name: Sign app APK braveConscrypt
uses: r0adkll/sign-android-release@v1
# ID used to access action output
id: sign_app_conscrypt
with:
releaseDirectory: app/build/outputs/apk/braveConscrypt/release
signingKeyBase64: ${{ secrets.RELEASE_KEYSTORE }}
#alias: ${{ secrets.ALIAS }}
alias: alias_name
keyStorePassword: ${{ secrets.RELEASE_KEYSTORE_PASS }}
#keyPassword: ${{ secrets.RELEASE_KEYSTORE_PASS }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
- name: Sign app APK braveLegacy
uses: r0adkll/sign-android-release@v1
# ID used to access action output
id: sign_app_legacy
with:
releaseDirectory: app/build/outputs/apk/braveLegacy/release
signingKeyBase64: ${{ secrets.RELEASE_KEYSTORE }}
#alias: ${{ secrets.ALIAS }}
alias: alias_name
keyStorePassword: ${{ secrets.RELEASE_KEYSTORE_PASS }}
#keyPassword: ${{ secrets.RELEASE_KEYSTORE_PASS }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
- name: Upload brave artifact APK
uses: actions/upload-artifact@v3
with:
name: brave
path: ${{steps.sign_app.outputs.signedReleaseFile}}
#path: app/build/outputs/apk/brave/release/*.apk
- name: Upload braveConscrypt artifact APK
uses: actions/upload-artifact@v3
with:
name: braveConscrypt
path: ${{steps.sign_app_conscrypt.outputs.signedReleaseFile}}
- name: Upload braveLegacy artifact APK
uses: actions/upload-artifact@v3
with:
name: braveLegacy
path: ${{steps.sign_app_legacy.outputs.signedReleaseFile}}
# evermind: How to get just the tag name? -> https://github.community/t/how-to-get-just-the-tag-name/16241/11
- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
# evermind
- name: rename apk and create checksum
id: renamed_apk
env:
SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }}
SOURCE_BRANCH: ${{ steps.branch_name.outputs.SOURCE_BRANCH }}
SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
SIGNED_APK: ${{ steps.sign_app.outputs.signedReleaseFile }}
SIGNED_APK_CONSCRYPT: ${{ steps.sign_app_conscrypt.outputs.signedReleaseFile }}
SIGNED_APK_LEGACY: ${{ steps.sign_app_legacy.outputs.signedReleaseFile }}
run: |
echo ::set-output name=RENAMED_APK::${SIGNED_APK%/*}/BraveNewPipe_${SOURCE_TAG}.apk
cp ${SIGNED_APK} ${SIGNED_APK%/*}/BraveNewPipe_${SOURCE_TAG}.apk
cd ${SIGNED_APK%/*}
sha256sum BraveNewPipe_${SOURCE_TAG}.apk > BraveNewPipe_${SOURCE_TAG}.apk.sha256
cd -
echo ::set-output name=RENAMED_APK_CONSCRYPT::${SIGNED_APK_CONSCRYPT%/*}/BraveNewPipe_conscrypt_${SOURCE_TAG}.apk
cp ${SIGNED_APK_CONSCRYPT} ${SIGNED_APK_CONSCRYPT%/*}/BraveNewPipe_conscrypt_${SOURCE_TAG}.apk
cd ${SIGNED_APK_CONSCRYPT%/*}
sha256sum BraveNewPipe_conscrypt_${SOURCE_TAG}.apk > BraveNewPipe_conscrypt_${SOURCE_TAG}.apk.sha256
cd -
echo ::set-output name=RENAMED_APK_LEGACY::${SIGNED_APK_LEGACY%/*}/BraveNewPipe_legacy_${SOURCE_TAG}.apk
cp ${SIGNED_APK_LEGACY} ${SIGNED_APK_LEGACY%/*}/BraveNewPipe_legacy_${SOURCE_TAG}.apk
cd ${SIGNED_APK_LEGACY%/*}
sha256sum BraveNewPipe_legacy_${SOURCE_TAG}.apk > BraveNewPipe_legacy_${SOURCE_TAG}.apk.sha256
cd -
# evermind: how to autorelease?: https://github.com/marvinpinto/action-automatic-releases
- name: auto release
uses: "evermind-zz/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
changelog_file: "customChangeLogFile"
files: |
${{ steps.renamed_apk.outputs.RENAMED_APK }}
${{ steps.renamed_apk.outputs.RENAMED_APK }}.sha256
${{ steps.renamed_apk.outputs.RENAMED_APK_CONSCRYPT }}
${{ steps.renamed_apk.outputs.RENAMED_APK_CONSCRYPT }}.sha256
${{ steps.renamed_apk.outputs.RENAMED_APK_LEGACY }}
${{ steps.renamed_apk.outputs.RENAMED_APK_LEGACY }}.sha256
id: "automatic_releases"
- name: "Automatically update json api data repository"
env:
GITHUB_SUPER_TOKEN: ${{ secrets.MY_GITHUB_SUPER_TOKEN }}
RENAMED_APK: ${{ steps.renamed_apk.outputs.RENAMED_APK }}
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
run: |
./.github/scripts/brave-new-pipe-releast-actions.sh "$AUTOMATIC_RELEASES_TAG" "${RENAMED_APK}" "customChangeLogFile"
# evermind - name: pack all app dir
# evermind run: tar czpf apper.tgz app
# evermind - name: Upload app dir artifact more stuff
# evermind uses: actions/upload-artifact@v2
# evermind with:
# evermind name: appDir
# evermind path: apper.tgz
#- name: upload artefact to App Center
# uses: wzieba/AppCenter-Github-Action@v1
# with:
# appName: ronakukani/Github-Actions-Demo
# token: ${{secrets.APP_CENTER_TOKEN}}
# group: Testers
# file: app/build/outputs/apk/release/app-release.apk
# notifyTesters: true
# debug: false
# releaseNotes: "here is your release note"
#- name: Send message to ms teams
# uses: dhollerbach/[email protected]
# with:
# webhook: 'Here is your Microsoft Teams Webhook URL'
# message: 'Here is your message'