Skip to content

Commit 4fedeab

Browse files
committed
Use properties for configuration
1 parent 0f95516 commit 4fedeab

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

.github/actions/android/action.yml

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
name: "Build Android library"
22
description: "Create artifact for Android library"
33
inputs:
4-
gpg-key:
5-
required: false
6-
description: "The GPG key to use when signing the publication"
7-
gpg-password:
8-
required: false
9-
description: "Password for the GPG key."
4+
sign-publication:
5+
description: "Whether to sign the built library"
6+
default: '1'
107

118
runs:
129
using: "composite"
@@ -31,14 +28,21 @@ runs:
3128
i686-linux-android
3229
cargo install cargo-ndk
3330
34-
- name: Build for Android
31+
- name: Build signed library
3532
shell: bash
36-
env:
37-
GPG_PRIVATE_KEY: ${{ inputs.gpg-key }}
38-
GPG_PASSWORD: ${{ inputs.gpg-password }}
33+
if: ${{ inputs.sign-publication == '1' }}
3934
run: |
4035
cd android
41-
./gradlew build publishAllPublicationsToHereRepository
36+
./gradlew build publishAllPublicationsToHereRepository -PgpgKey=${{ secrets.GPG_PRIVATE_KEY }} -PgpgPassword=${{ secrets.GPG_PASSWORD }}
37+
ls -lh build/outputs/aar
38+
find build/repository
39+
40+
- name: Build library without signing
41+
shell: bash
42+
if: ${{ inputs.sign-publication == '0' }}
43+
run: |
44+
cd android
45+
./gradlew build publishAllPublicationsToHereRepository -PsignPublication=0
4246
ls -lh build/outputs/aar
4347
find build/repository
4448

.github/workflows/android.yml

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ jobs:
1313
submodules: true
1414
- name: Build Android
1515
uses: ./.github/actions/android
16+
with:
17+
sign-publication: '0'

.github/workflows/release.yml

-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ jobs:
4242
submodules: true
4343
- name: Build Android
4444
uses: ./.github/actions/android
45-
with:
46-
gpg-key: ${{ secrets.GPG_PRIVATE_KEY }}
47-
gpg-password: ${{ secrets.GPG_PASSWORD }}
4845

4946
publish_android:
5047
permissions:

android/build.gradle.kts

+12-8
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,18 @@ publishing {
129129
}
130130

131131
signing {
132-
val privateKey = System.getenv("GPG_PRIVATE_KEY")
133-
134-
if (privateKey == null || privateKey == "null") {
135-
// Don't sign the publication.
136-
} else {
137-
var signingKey = String(Base64.getDecoder().decode(System.getenv("GPG_PRIVATE_KEY"))).trim()
138-
var signingPassword = System.getenv("GPG_PASSWORD")
139-
useInMemoryPgpKeys(signingKey, signingPassword)
132+
val sign = providers.gradleProperty("signPublication").getOrElse("1")
133+
134+
if (sign != "0") {
135+
val key = providers.gradleProperty("gpgKey")
136+
val password = providers.gradleProperty("gpgPassword")
137+
138+
if (key.isPresent()) {
139+
val signingKey = String(Base64.getDecoder().decode(key.get())).trim()
140+
useInMemoryPgpKeys(signingKey, password.get())
141+
} else {
142+
useGpgCmd()
143+
}
140144

141145
sign(publishing.publications)
142146
}

0 commit comments

Comments
 (0)