Skip to content

Commit

Permalink
Enable configuration cache & Fix publishing (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxalbert1996 authored Aug 31, 2024
1 parent e5b8202 commit fc6733e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 32 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ jobs:
timeout-minutes: 30

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v4
with:
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}

- name: Build and test
run: ./gradlew assemble apiCheck testDebugUnitTest
20 changes: 10 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ jobs:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Prepare environment
env:
GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }}
run: sh -c "mkdir -p ~/.gradle && echo '${GRADLE_PROPERTIES}' > ~/.gradle/gradle.properties"

- name: Setup JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v4
with:
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}

- name: Publish
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
run: ./gradlew --no-daemon publish
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_IN_MEMORY_KEY_PASSWORD }}
run: ./gradlew --no-configuration-cache publishAllPublicationsToMavenCentralRepository
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ org.gradle.jvmargs=-Xmx2048m -Dkotlin.daemon.jvm.options\="-Xmx2048M" -XX:+UsePa
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
org.gradle.configuration-cache=true
org.gradle.configureondemand=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
Expand Down
21 changes: 2 additions & 19 deletions sample/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.io.ByteArrayOutputStream

plugins {
kotlin("android")
id("com.android.application")
Expand All @@ -22,24 +20,9 @@ android {
targetSdk = libs.versions.sdk.target.get().toInt()
resourceConfigurations += "en"
val libVersion = property("VERSION_NAME") as String
val isSnapshot = libVersion.endsWith("SNAPSHOT")
val appVersion = if (isSnapshot) {
ByteArrayOutputStream().use { os ->
exec {
setCommandLine("git", "describe", "--tags")
standardOutput = os
}
os.toString()
}
} else libVersion
val (version, commitCount) = if (isSnapshot) {
val description = appVersion.split('-')
description[0] to description[1].toInt()
} else {
libVersion to 0
}
val appVersion = libVersion.substringBefore('-')
versionName = appVersion
versionCode = commitCount + version.split('.')
versionCode = appVersion.split('.')
.fold(0) { result, number -> (result + number.toInt()) * 100 }
}

Expand Down

0 comments on commit fc6733e

Please sign in to comment.