Skip to content

Commit

Permalink
Fix artifact signing
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zinnatullin committed Sep 30, 2019
1 parent 179f2d3 commit 2787785
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
11 changes: 6 additions & 5 deletions ci
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
# You can run it from any directory.
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

pushd "$PROJECT_DIR"
pushd "$PROJECT_DIR" > /dev/null

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

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

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

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

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

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

# Run closeAndReleaseRepository separately to avoid contention between publishing and closing.
./gradlew --stacktrace --info closeAndReleaseRepository
Expand Down
5 changes: 5 additions & 0 deletions gradle/publish-android.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ task javadocJar(type: Jar, dependsOn: dokka) {
from dokka.outputDirectory
}

artifacts {
archives sourcesJar
archives javadocJar
}

project.afterEvaluate {
publishing {
publications {
Expand Down
8 changes: 5 additions & 3 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ task validatePublishing {
}
}

signing {
required { gradle.taskGraph.hasTask("publishToSonatype") }
sign configurations.archives
afterEvaluate {
signing {
required { gradle.taskGraph.hasTask("publishToSonatype") }
sign publishing.publications.LibraryPublication
}
}

nexusPublishing {
Expand Down

0 comments on commit 2787785

Please sign in to comment.