Skip to content

Commit 2787785

Browse files
Fix artifact signing
1 parent 179f2d3 commit 2787785

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

ci

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44
# You can run it from any directory.
55
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
66

7-
pushd "$PROJECT_DIR"
7+
pushd "$PROJECT_DIR" > /dev/null
88

99
# Export "PUBLISH_RELEASE=true" to initiate release process.
1010
if [ "${PUBLISH_RELEASE:-}" != "true" ]; then
@@ -13,22 +13,22 @@ if [ "${PUBLISH_RELEASE:-}" != "true" ]; then
1313
else
1414
echo "Launching release publishing process..."
1515

16-
if [ -z "$GPG_SECRET_KEYS" ]; then
16+
if [ -z "${GPG_SECRET_KEYS:-}" ]; then
1717
echo "Put base64 encoded gpg secret key for signing into GPG_SECRET_KEYS env variable."
1818
exit 1
1919
fi
2020

21-
if [ -z "$GPG_OWNERTRUST" ]; then
21+
if [ -z "${GPG_OWNERTRUST:-}" ]; then
2222
echo "Put base64 encoded gpg ownertrust for signing into GPG_OWNERTRUST env variable."
2323
exit 1
2424
fi
2525

26-
if [ -z "$GPG_KEY_ID" ]; then
26+
if [ -z "${GPG_KEY_ID:-}" ]; then
2727
echo "Put GPG key id into GPG_KEY_ID env variable."
2828
exit 1
2929
fi
3030

31-
if [ -z "$GPG_PASSPHRASE" ]; then
31+
if [ -z "${GPG_PASSPHRASE:-}" ]; then
3232
echo "Put GPG passphrase into GPG_PASSPHRASE env variable."
3333
exit 1
3434
fi
@@ -54,6 +54,7 @@ else
5454
unset GPG_OWNERTRUST
5555

5656
./gradlew --stacktrace --info build publishToSonatype -Psigning.keyId="$GPG_KEY_ID" -Psigning.password="$GPG_PASSPHRASE" -Psigning.secretKeyRingFile="$HOME/.gnupg/secring.gpg"
57+
unset GPG_PASSPHRASE
5758

5859
# Run closeAndReleaseRepository separately to avoid contention between publishing and closing.
5960
./gradlew --stacktrace --info closeAndReleaseRepository

gradle/publish-android.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ task javadocJar(type: Jar, dependsOn: dokka) {
1010
from dokka.outputDirectory
1111
}
1212

13+
artifacts {
14+
archives sourcesJar
15+
archives javadocJar
16+
}
17+
1318
project.afterEvaluate {
1419
publishing {
1520
publications {

gradle/publish.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ task validatePublishing {
3333
}
3434
}
3535

36-
signing {
37-
required { gradle.taskGraph.hasTask("publishToSonatype") }
38-
sign configurations.archives
36+
afterEvaluate {
37+
signing {
38+
required { gradle.taskGraph.hasTask("publishToSonatype") }
39+
sign publishing.publications.LibraryPublication
40+
}
3941
}
4042

4143
nexusPublishing {

0 commit comments

Comments
 (0)