Skip to content

Instantly share code, notes, and snippets.

@PabloCasia
Last active February 19, 2023 01:23
Show Gist options
  • Save PabloCasia/bc2c9908df4803aafa804bc1be85b1a4 to your computer and use it in GitHub Desktop.
Save PabloCasia/bc2c9908df4803aafa804bc1be85b1a4 to your computer and use it in GitHub Desktop.
Android GitHub Actions Post
openssl base64 < playstore.keystore.jks | tr -d '\n' | tee keystore_base64_encoded.txt
- name: Build Release AAB
run: ./gradlew
-PKEYSTORE_FILE="../${{ /your_path_to/playstore.keystore.jks }}"
-PKEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}
-PSIGNING_KEY_ALIAS=${{ secrets.SIGNING_KEY_ALIAS }}
-PSIGNING_KEY_PASSWORD=${{ secrets.SIGNING_KEY_PASSWORD }}
app:bundleRelease
- name: Build Release AAB
run: ./gradlew app:bundleRelease
buildTypes {
getByName("debug") {
// your configuration here
signingConfig = signingConfigs.getByName(name)
}
getByName("release") {
// your configuration here
signingConfig = signingConfigs.getByName(name)
}
}
./gradlew bundle
- name: Run Linters and Test
run: ./gradlew check
- name: Deploy to Play Store
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: your.app.package
releaseFiles: app/build/outputs/bundle/release/*.aab
track: internal
storePassword = System.getenv("KEYSTORE_PASSWORD")
KEYSTORE_FILE=/your_path_to/playstore.keystore.jks
KEYSTORE_PASSWORD=your_keystore_password
SIGNING_KEY_ALIAS=your_signing_key_alias
SIGNING_KEY_PASSWORD=your_signing_key_password
# Cache Gradle dependencies and Gradle Wrapper
- name: Setup Gradle Cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
- name: Make gradlew executable
run: chmod +x ./gradlew
name: "Gradle Wrapper Validation"
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
# Run Gradle Wrapper Validation Action to verify the Wrapper's checksum
gradle-validation:
name: Gradle Wrapper
runs-on: [ self-hosted ]
steps:
# Checkout current repository
- name: Fetch Sources
uses: actions/checkout@v2
# Validate Wrapper
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Run Ktlint
run: ./gradlew ktlintStagingDebugCheck
- name: Run Unit Tests
run: ./gradlew testStagingDebugUnitTest
- name: Restore playstore.keystore.jks
run: echo $KEYSTORE_FILE | base64 -d > /your_path_to/playstore.keystore.jks
- name: Restore gradle.properties
run: |
mkdir -p ~/.gradle/
echo "KEYSTORE_FILE=/your_path_to/playstore.keystore.jks" >> ~/.gradle/gradle.properties
echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> ~/.gradle/gradle.properties
echo "SIGNING_KEY_ALIAS=${{ secrets.SIGNING_KEY_ALIAS }}" >> ~/.gradle/gradle.properties
echo "SIGNING_KEY_PASSWORD=${{ secrets.SIGNING_KEY_PASSWORD }}" >> ~/.gradle/gradle.properties
shell: bash
- name: Release
id: create_release
uses: actions/create-release@v1
with:
release_name: Release v.${{ env.VERSION_NAME }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Reports
uses: actions/upload-artifact@v2
with:
name: Test-Reports
path: app/build/reports
if: always()
- name: Fetch Sources
uses: actions/checkout@v2
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
signingConfigs {
create("release") {
storeFile = file(project.property("KEYSTORE_FILE").toString())
storePassword = project.property("KEYSTORE_PASSWORD").toString()
keyAlias = project.property("SIGNING_KEY_ALIAS").toString()
keyPassword = project.property("SIGNING_KEY_PASSWORD").toString()
}
}
# Workflow name
name: Release App
# When it will be triggered
on:
push:
branches:
- main
# Where it will run
jobs:
build:
runs-on: ubuntu-latest
- name: Upload Release APK
id: upload_release_asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/apk/release/app-release.apk
asset_name: signed-artifact.apk
asset_content_type: application/zip
- name: Generate App Version Name
run: echo "VERSION_NAME=$(git describe --tags | sed 's/\(.*\)-/\1./' | sed 's/\(.*\)-/\1+/')" >> $GITHUB_ENV
- name: Bump Version
uses: chkfung/android-version-actions@v1.1
with:
gradlePath: app/build.gradle.kts
versionCode: ${{ github.run_number }}
versionName: ${{ env.VERSION_NAME }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment