Skip to content

Commit

Permalink
Add signing and local publication.
Browse files Browse the repository at this point in the history
  • Loading branch information
ziswb committed Sep 20, 2024
1 parent 536885a commit 5622632
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
22 changes: 22 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ plugins {
alias(libs.plugins.detekt)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.spotless)
`maven-publish`
signing
}

group = "ch.ergon.todochecker"
Expand Down Expand Up @@ -51,6 +53,26 @@ spotless {
ktlint()
}
}
publishing {
publications {
create<MavenPublication>("gradle-plugin") {
from(components["java"])
}
repositories {
maven {
name = "local"
url = uri(layout.buildDirectory.dir("local-repo"))
}
}
}
}

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["gradle-plugin"])
}

tasks.register("resolveAndLockAll") {
doFirst {
Expand Down
19 changes: 19 additions & 0 deletions scripts/require-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

command="${1}"
RESOLVED_COMMAND=""


if hash "${command}" 2>/dev/null; then
RESOLVED_COMMAND=$(command -v "${command}")
else
(echo >&2 "ERROR: ${1} is not installed.")
(echo >&2 "Make sure ${1} is installed and on your PATH.")
exit 1
fi

echo "${RESOLVED_COMMAND}"
29 changes: 29 additions & 0 deletions scripts/sign-and-publish-locally.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# exit on error
set -e
# exit on undefined variables
set -u
# return the command that was the reason behind the failure
set -o pipefail

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
REQUIRE_COMMAND="${SCRIPT_DIR}/require-command.sh"
GRADLE="${SCRIPT_DIR}/../gradlew"

OP_CMD=$("${REQUIRE_COMMAND}" op)
SIGNING_KEY=$(${OP_CMD} read --account ergon.1password.eu "op://CoP CD/Gradle Todo Checker PlugIn Signing Keys/Signing Keys/private key")
SIGNING_KEY_PASSWORD=$(${OP_CMD} read --no-newline --account ergon.1password.eu "op://CoP CD/Gradle Todo Checker PlugIn Signing Keys/password")

ORG_GRADLE_PROJECT_signingKey="${SIGNING_KEY}"
ORG_GRADLE_PROJECT_signingPassword="${SIGNING_KEY_PASSWORD}"
export ORG_GRADLE_PROJECT_signingKey
export ORG_GRADLE_PROJECT_signingPassword

"${GRADLE}" clean sign
"${GRADLE}" clean publishTodoCheckerPluginPublicationToLocalRepository

unset SIGNING_KEY
unset ORG_GRADLE_PROJECT_signingKey
unset SIGNING_KEY_PASSWORD
unset ORG_GRADLE_PROJECT_signingPassword

0 comments on commit 5622632

Please sign in to comment.