Skip to content

Commit f87a023

Browse files
author
Hussein Habibi Juybari
committed
Refactor build configuration to use getSecret function for credentials; update Java SDK version in project settings
1 parent c08dddf commit f87a023

4 files changed

Lines changed: 52 additions & 12 deletions

File tree

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: chmod +x gradlew
3939

4040
- name: Build
41-
run: ./gradlew :logtap:assembleRelease
41+
run: ./gradlew :logtap:assembleRelease :logtap-noop:assembleRelease
4242

4343
- name: Publish to Central (no staging)
4444
env:
@@ -48,4 +48,4 @@ jobs:
4848
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
4949
PUBLISH_VERSION: ${{ env.PUBLISH_VERSION }}
5050
run: |
51-
./gradlew publish --stacktrace
51+
./gradlew :logtap:publish :logtap-noop:publish --stacktrace

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LogTap-Noop/build.gradle.kts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.util.Properties
2+
13
plugins {
24
alias(libs.plugins.android.library)
35
alias(libs.plugins.kotlin.android)
@@ -95,17 +97,35 @@ publishing {
9597
name = "Central"
9698
url = uri("https://central.sonatype.com/repository/maven-releases/")
9799
credentials {
98-
username = System.getenv("OSSRH_USERNAME") // token id
99-
password = System.getenv("OSSRH_PASSWORD") // token secret
100+
username = getSecret("OSSRH_USERNAME") // token id
101+
password = getSecret("OSSRH_PASSWORD") // token secret
100102
}
101103
}
102104
}
103105
}
104106

105107
signing {
106108
useInMemoryPgpKeys(
107-
System.getenv("SIGNING_KEY"), // base64(ASCII-armored private key)
108-
System.getenv("SIGNING_PASSWORD")
109+
getSecret("SIGNING_KEY"), // base64(ASCII-armored private key)
110+
getSecret("SIGNING_PASSWORD")
109111
)
110112
sign(publishing.publications)
111-
}
113+
}
114+
115+
fun getSecret(name: String): String? {
116+
// 1) env (CI)
117+
System.getenv(name)?.let { return it }
118+
119+
// 2) gradle.properties (root or ~/.gradle)
120+
providers.gradleProperty(name).orNull?.let { return it }
121+
122+
// 3) local.properties (manual load)
123+
val lp = Properties()
124+
val f = rootProject.file("local.properties")
125+
if (f.exists()) f.inputStream().use { lp.load(it) }
126+
val key = lp.getProperty(name)
127+
128+
println("===========> KEY $name is ${if (key == null) "NULL" else "HAS IT"} <============")
129+
130+
return key
131+
}

LogTap/build.gradle.kts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.util.Properties
2+
13
plugins {
24
alias(libs.plugins.kotlin.serialization)
35
alias(libs.plugins.android.library)
@@ -75,8 +77,8 @@ afterEvaluate {
7577
url = uri("https://central.sonatype.com/repository/maven-releases/")
7678
credentials {
7779
// Use Central Portal Publishing Token
78-
username = System.getenv("OSSRH_USERNAME") // token id
79-
password = System.getenv("OSSRH_PASSWORD") // token secret
80+
username = getSecret("OSSRH_USERNAME") // token id
81+
password = getSecret("OSSRH_PASSWORD")// token secret
8082
}
8183
}
8284
}
@@ -86,8 +88,26 @@ afterEvaluate {
8688

8789
signing {
8890
useInMemoryPgpKeys(
89-
System.getenv("SIGNING_KEY"),
90-
System.getenv("SIGNING_PASSWORD")
91+
getSecret("SIGNING_KEY"),
92+
getSecret("SIGNING_PASSWORD")
9193
)
9294
sign(publishing.publications)
95+
}
96+
97+
fun getSecret(name: String): String? {
98+
// 1) env (CI)
99+
System.getenv(name)?.let { return it }
100+
101+
// 2) gradle.properties (root or ~/.gradle)
102+
providers.gradleProperty(name).orNull?.let { return it }
103+
104+
// 3) local.properties (manual load)
105+
val lp = Properties()
106+
val f = rootProject.file("local.properties")
107+
if (f.exists()) f.inputStream().use { lp.load(it) }
108+
val key = lp.getProperty(name)
109+
110+
println("===========> KEY $name is ${if (key == null) "NULL" else "HAS IT"} <============")
111+
112+
return key
93113
}

0 commit comments

Comments
 (0)