From 8564938b1f1930e47f3a3f0dba3212bb0ba7969e Mon Sep 17 00:00:00 2001 From: Ash Date: Wed, 20 Apr 2022 01:36:34 +0800 Subject: [PATCH] GitHub Workflows switched to Release --- .github/workflows/build_commit.yaml | 16 ++++++++++++---- .gitignore | 3 ++- .gitmodules | 3 +++ ReadYouSecret | 1 + app/build.gradle | 23 ++++++++++++++++++++++- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .gitmodules create mode 160000 ReadYouSecret diff --git a/.github/workflows/build_commit.yaml b/.github/workflows/build_commit.yaml index 62f89fd..99f544c 100644 --- a/.github/workflows/build_commit.yaml +++ b/.github/workflows/build_commit.yaml @@ -1,20 +1,28 @@ -name: "Build + Upload artifacts" +name: "Build Commit" on: push jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - uses: actions/setup-java@v2 with: distribution: temurin java-version: 11 + - uses: actions/checkout@v2 + - name: Checkout Android Keystore + uses: actions/checkout@v2 + with: + repository: Ashinch/ReadYouSecret + token: ${{ secrets.ReadYouSecretToken }} + path: ReadYouSecret + ref: main + - uses: gradle/gradle-build-action@v2 - - run: gradle assembleDebug + - run: gradle assembleRelease - uses: actions/upload-artifact@v3 with: name: ${{ github.sha }} - path: app/build/outputs/apk/debug/app-debug.apk + path: app/build/outputs/apk/release/*.apk \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2b3d2fe..4e16dde 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ gen/ # Gradle files .gradle/ build/ +release/ # Local configuration file (sdk path, etc) local.properties @@ -25,7 +26,7 @@ proguard/ # Log Files *.log -# Android Studio Navigation editor temp files +# Android Studio .navigation/ # Android Studio captures folder diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1e0c0dd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ReadYouSecret"] + path = ReadYouSecret + url = git@github.com:Ashinch/ReadYouSecret.git diff --git a/ReadYouSecret b/ReadYouSecret new file mode 160000 index 0000000..dae3bdc --- /dev/null +++ b/ReadYouSecret @@ -0,0 +1 @@ +Subproject commit dae3bdcacacc75eecb43a93b97238adaa8dae539 diff --git a/app/build.gradle b/app/build.gradle index 8984b34..971e099 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,6 +6,14 @@ plugins { id "androidx.navigation.safeargs.kotlin" } +def gitCommitHash = 'git rev-parse --verify --short HEAD'.execute().text.trim() +def keyProps = new Properties() +def keyPropsFile = rootProject.file('ReadYouSecret/keystore.properties') +if (keyPropsFile.exists()) { + println("Loading keystore properties from ${keyPropsFile.absolutePath}") + keyProps.load(new FileInputStream(keyPropsFile)) +} + android { compileSdk 32 @@ -21,12 +29,25 @@ android { useSupportLibrary true } } - + signingConfigs { + release { + keyAlias keyProps['keyAlias'] + keyPassword keyProps['keyPassword'] + storeFile keyProps['storeFile'] ? file(keyProps['storeFile']) : null + storePassword keyProps['storePassword'] + } + } buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + applicationVariants.all { variant -> + variant.outputs.each { output -> + output.outputFileName = "ReadYou-${defaultConfig.versionName}-${gitCommitHash}.apk" } } kotlinOptions {