diff --git a/.github/workflows/pr_pre_check.yml b/.github/workflows/pr_pre_check.yml index 8dc51f7c..754fd85e 100644 --- a/.github/workflows/pr_pre_check.yml +++ b/.github/workflows/pr_pre_check.yml @@ -1,31 +1,45 @@ -name: PR Basic Check +name: Basic Check on: pull_request: types: [opened,reopened,synchronize] branches: - master - - dev jobs: + check: + name: Check + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - name: Skip duplicate actions + uses: fkirc/skip-duplicate-actions@v5 + with: + cancel_others: true + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 17 + cache: 'gradle' + - uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: wrapper + gradle-home-cache-cleanup: true +# - run: ./gradlew spotlessCheck simple_compile: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v4 with: - distribution: 'adopt' + distribution: 'zulu' java-version: 17 - - name: Cache Gradle - uses: actions/cache@v2 + cache: 'gradle' + - uses: gradle/actions/setup-gradle@v3 with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: gradle-app-${{ github.sha }} - restore-keys: | - gradle- - + gradle-version: wrapper + gradle-home-cache-cleanup: true - name: Build apk with Gradle - run: bash ./gradlew assembleRelease --scan --debug + run: ./gradlew :app:assembleDebug diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..9e299bc0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +name: Generated APK AAB (Upload - Create Artifact To Github Action) + +env: + # The name of the main module repository + main_project_module: app + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - id: fetchLatestRelease + uses: pozetroninc/github-action-get-latest-release@master + with: + repository: ${{ github.repository }} + excludes: prerelease, draft + token: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare Release Artifact + uses: dsaltares/fetch-gh-release-asset@master + with: + repo: 'dsaltares/godot-wild-jam-18' + version: ${{ steps.keydb.fetchLatestRelease.release }} + file: '*.aab' + token: ${{ secrets.GITHUB_TOKEN }} + - name: Upload Android Release to Play Store + uses: r0adkll/upload-google-play@v1.1.3 + with: + serviceAccountJsonPlainText: ${{ SERVICE_ACCOUNT_JSON }} + packageName: me.rosuh.easywatermark + releaseFiles: '*.aab' + track: production + status: inProgress + mappingFile: app/build/outputs/mapping/release/mapping.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6ea552ef..be75e6d3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,56 +1,97 @@ -name: Android CI +name: Generated APK AAB (Upload - Create Artifact To Github Action) + +env: + # The name of the main module repository + main_project_module: app on: + # on merge to master push: - tags: - - "*" + branches: + - master + paths-ignore: + - '.idea/**' + - '.gitattributes' + - '.github/**.json' + - '.gitignore' + - '.gitmodules' + - '**.md' + - 'LICENSE' + - 'NOTICE' jobs: + check: + name: Check + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - name: Skip duplicate actions + uses: fkirc/skip-duplicate-actions@v5 + with: + cancel_others: true + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 17 + cache: 'gradle' + - uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: wrapper + gradle-home-cache-cleanup: true +# - run: ./gradlew spotlessCheck build: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - - uses: actions/checkout@v2 + - name: Skip duplicate actions + uses: fkirc/skip-duplicate-actions@v5 + with: + cancel_others: true + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v4 with: - distribution: 'adopt' + distribution: 'zulu' java-version: 17 - - name: Cache Gradle - uses: actions/cache@v2 + cache: 'gradle' + - uses: gradle/actions/setup-gradle@v3 with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: gradle-app-${{ github.sha }} - restore-keys: | - gradle- - - - name: Build apk with Gradle - run: bash ./gradlew assembleRelease - - - name: Build bundle with Gradle - run: bash ./gradlew bundleRelease - + gradle-version: wrapper + gradle-home-cache-cleanup: true + - name: Retrieve version + run: | + echo VERSION=$(echo ${{ github.event.head_commit.id }} | head -c 10) >> $GITHUB_ENV + # Set Repository Name As Env Variable + - name: Set repository name as env variable + run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + # Create APK Release + - name: Build apk release project (APK) - ${{ env.main_project_module }} module + run: ./gradlew -PappVerName=${{ env.VERSION }} ${{ env.main_project_module }}:assembleRelease + # Create Bundle AAB Release + # Noted for main module build [main_project_module]:bundleRelease + - name: Build app bundle release (AAB) - ${{ env.main_project_module }} module + run: ./gradlew ${{ env.main_project_module }}:bundleRelease + - name: Sign apk release if: success() id: sign_apk uses: r0adkll/sign-android-release@v1.0.4 env: - BUILD_TOOLS_VERSION: "31.0.0" + BUILD_TOOLS_VERSION: "34.0.0" with: releaseDirectory: app/build/outputs/apk/release signingKeyBase64: ${{ secrets.SIGNING_KEY }} alias: ${{ secrets.ALIAS }} keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} keyPassword: ${{ secrets.KEY_PASSWORD }} - - name: Sign bundle release if: success() id: sign_bundle uses: r0adkll/sign-android-release@v1.0.4 env: - BUILD_TOOLS_VERSION: "31.0.0" + BUILD_TOOLS_VERSION: "34.0.0" with: releaseDirectory: app/build/outputs/bundle/release signingKeyBase64: ${{ secrets.SIGNING_KEY }} @@ -67,4 +108,4 @@ jobs: files: | app/build/outputs/apk/release/*-signed.apk app/build/outputs/bundle/release/*.aab - app/build/outputs/mapping/release/mapping.txt + app/build/outputs/mapping/release/mapping.txt \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5d7cf6ab..47917385 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,4 +1,4 @@ -import com.android.build.gradle.internal.api.BaseVariantOutputImpl +import com.android.build.gradle.internal.api.ApkVariantOutputImpl plugins { id(libs.plugins.android.application.get().pluginId) @@ -6,6 +6,22 @@ plugins { id(libs.plugins.kotlin.parcelize.get().pluginId) id(libs.plugins.ksp.get().pluginId) id(libs.plugins.hilt.plugin.get().pluginId) + id(libs.plugins.spotless.get().pluginId) +} + +/** + * read version from gradle.properties + */ +val majorVersion by properties +val minorVersion by properties +val patchVersion by properties + +fun getVersionCode(): Int { + return (majorVersion as String).toInt() * 10000 + (minorVersion as String).toInt() * 100 + (patchVersion as String).toInt() +} + +fun getVersionName(): String { + return "$majorVersion.$minorVersion.$patchVersion" } android { @@ -15,10 +31,9 @@ android { applicationId = "me.rosuh.easywatermark" minSdk = (Apps.minSdk) targetSdk = (Apps.targetSdk) - versionCode = 20900 - versionName = "2.9.0" + versionCode = getVersionCode() + versionName = getVersionName() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - setProperty("archivesBaseName", "$applicationId-v$versionName($versionCode)") } buildTypes { @@ -46,14 +61,6 @@ android { } } - // change output apk name - applicationVariants.all { - outputs.all { - (this as? BaseVariantOutputImpl)?.outputFileName = - "$applicationId-v$versionName($versionCode).apk" - } - } - packagingOptions { resources.excludes.add("DebugProbesKt.bin") } @@ -62,13 +69,6 @@ android { namespace = "me.rosuh.easywatermark" -// lint { -// baseline = file("lint-baseline.xml") -// quiet = true -// abortOnError = false -// checkReleaseBuilds = false -// } - buildFeatures { compose = true } @@ -80,6 +80,13 @@ android { kotlin { jvmToolchain(17) } + + applicationVariants.configureEach { + outputs.configureEach { + (this as? ApkVariantOutputImpl)?.outputFileName = + "EasyWatermark-$versionName-$versionCode.apk" + } + } } diff --git a/build.gradle.kts b/build.gradle.kts index 5c80e4d5..bbe58d53 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +import com.diffplug.gradle.spotless.SpotlessExtension + buildscript { repositories { mavenCentral() @@ -13,27 +15,21 @@ buildscript { } -tasks.register("clean", Delete::class) { - delete(rootProject.buildDir) -} - -//apply(plugin = "org.jlleitschuh.gradle.ktlint") -// -//subprojects { -// apply(plugin = "org.jlleitschuh.gradle.ktlint") // Version should be inherited from parent -// -// repositories { -// // Required to download KtLint -// mavenCentral() -// } -// -// // Optionally configure plugin -// configure { -// debug.set(true) -// } -//} - plugins { alias(libs.plugins.hilt) apply false alias(libs.plugins.ksp) apply false + alias(libs.plugins.spotless) apply false +} + +allprojects { + plugins.apply(rootProject.libs.plugins.spotless.get().pluginId) + extensions.configure { + kotlin { + target("src/**/*.kt") + ktlint(rootProject.libs.ktlint.get().version) + } + kotlinGradle { + ktlint(rootProject.libs.ktlint.get().version) + } + } } diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 089ef419..397ec0ab 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,6 +1,6 @@ object Apps { const val compileSdk = 34 - const val buildTools = "33.0.0" + const val buildTools = "34.0.0" const val minSdk = 23 - const val targetSdk = 33 + const val targetSdk = 34 } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 35526822..2ba0fd47 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,8 @@ org.gradle.unsafe.configuration-cache=true android.defaults.buildfeatures.buildconfig=true android.nonTransitiveRClass=false android.nonFinalResIds=false -#org.gradle.unsafe.configuration-cache=true \ No newline at end of file +#org.gradle.unsafe.configuration-cache=true + +majorVersion=2 +minorVersion=9 +patchVersion=1 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 27c455c9..a4ceb225 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -44,6 +44,7 @@ androidxComposeRuntimeTracing = "1.0.0-alpha04" accompanist = "0.33.2-alpha" coil = "2.4.0" material3 = "1.2.0-alpha09" +spotless = "7.0.0.BETA1" [plugins] android-application = { id = "com.android.application", version.ref = "agp" } @@ -55,8 +56,7 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } hilt-plugin = { id = "dagger.hilt.android.plugin", version.ref = "hilt" } - - +spotless = "com.diffplug.spotless:6.25.0" [libraries] agp = { module = "com.android.tools.build:gradle", version.ref = "agp" } @@ -99,7 +99,6 @@ coil-kt-svg = { group = "io.coil-kt", name = "coil-svg", version.ref = "coil" } dagger-hilt-plugin = { group = "com.google.dagger", name = "hilt-android-gradle-plugin", version.ref = "hilt" } tools-gradle = { group = "com.android.tools.build", name = "gradle", version.ref = "toolsGradle" } kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } -ktlint-gradle = { group = "org.jlleitschuh.gradle", name = "ktlint-gradle", version.ref = "ktlintGradle" } kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } kotlin-coroutine-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" } kotlin-coroutine-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" } @@ -144,3 +143,4 @@ mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mo mockito-android = { group = "org.mockito", name = "mockito-android", version.ref = "mockito" } robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" } hamcrest-library = { group = "org.hamcrest", name = "hamcrest-library", version.ref = "hamcrest" } +ktlint = "com.pinterest.ktlint:ktlint-cli:1.3.1" \ No newline at end of file