diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c9cd475..72f7775 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,9 +45,10 @@ jobs: if: github.ref == 'refs/heads/main' environment: Sonatype env: + ORG_GRADLE_PROJECT_sonatypePass: ${{ secrets.SONATYPE_API_KEY }} + ORG_GRADLE_PROJECT_sonatypeUser: ${{ secrets.SONATYPE_USER }} SONATYPE_GPG_KEY: ${{ secrets.SONATYPE_GPG_KEY }} SONATYPE_GPG_KEY_PASSWORD: ${{ secrets.SONATYPE_GPG_KEY_PASSWORD }} - SECRETS_KEY: ${{ secrets.SECRETS_KEY }} steps: - uses: actions/checkout@v4 - name: Set up JDK 17 diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index f671674..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,35 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - mavenCentral() -} - -tasks { - val ensureSecretsExist by registering { - val secretFile = File("$projectDir/src/main/kotlin/Secrets.kt") - description = "Ensures that '$secretFile' exists" - - outputs.file(secretFile) - doFirst { - if (!secretFile.exists()) { - secretFile.writeText( - """ -object Secrets { - object Sonatype { - const val user = "" - const val apiKey = "" - } -} - - """.trimIndent() - ) - } - } - } - - compileKotlin { - dependsOn(ensureSecretsExist) - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Secrets.kt.gpg b/buildSrc/src/main/kotlin/Secrets.kt.gpg deleted file mode 100644 index 41184fa..0000000 Binary files a/buildSrc/src/main/kotlin/Secrets.kt.gpg and /dev/null differ diff --git a/log4k-slf4j/build.gradle.kts b/log4k-slf4j/build.gradle.kts index c399ad8..74dd1db 100644 --- a/log4k-slf4j/build.gradle.kts +++ b/log4k-slf4j/build.gradle.kts @@ -72,14 +72,25 @@ publishing { } } +<<<<<<< Updated upstream repositories { maven { name = "sonatype" credentials { username = Secrets.Sonatype.user password = Secrets.Sonatype.apiKey +======= + if (hasProperty("sonatypeUser") && hasProperty("sonatypePass")) { + repositories { + maven { + name = "sonatype" + credentials { + username = property("sonatypeUser") as String + password = property("sonatypePass") as String + } + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") +>>>>>>> Stashed changes } - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") } } } diff --git a/log4k/build.gradle.kts b/log4k/build.gradle.kts index edb7036..07a8941 100644 --- a/log4k/build.gradle.kts +++ b/log4k/build.gradle.kts @@ -69,14 +69,25 @@ publishing { } } +<<<<<<< Updated upstream repositories { maven { name = "sonatype" credentials { username = Secrets.Sonatype.user password = Secrets.Sonatype.apiKey +======= + if (hasProperty("sonatypeUser") && hasProperty("sonatypePass")) { + repositories { + maven { + name = "sonatype" + credentials { + username = property("sonatypeUser") as String + password = property("sonatypePass") as String + } + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") +>>>>>>> Stashed changes } - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") } } } diff --git a/scripts/inc.functions.sh b/scripts/inc.functions.sh index 60ec8e9..46d9d35 100644 --- a/scripts/inc.functions.sh +++ b/scripts/inc.functions.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env sh # # Collection of shared functions # @@ -8,35 +8,36 @@ RED='\033[0;31m' YELLOW='\033[0;33m' NC='\033[0m' # No Color -function approve() { - echo -e "${GREEN}$@${NC}" +approve() { + printf "${GREEN}%s${NC}\n" "$*" } -function warn() { - echo -e "${YELLOW}$@${NC}" +warn() { + printf "${YELLOW}%s${NC}\n" "$*" } -function die() { - echo -e "${RED}$@${NC}" +die() { + printf "${RED}%s${NC}\n" "$*" exit 1 } -function safe() { +safe() { "$@" - local status=$? - if [[ ${status} -ne 0 ]]; then - die "\nBUILD FAILED\nAfter invoking \"$@\"\n" >&2 + _status=$? + if [ ${_status} -ne 0 ]; then + die "\nBUILD FAILED\nAfter invoking \"$*\"\n" >&2 fi - return ${status} + return ${_status} } -function sed2() { - sed -i'.bak' "$1" ${@:2} - for file in "${@:2}"; do +sed2() { + _args=$(echo "${@}" | cut -d" " -f2-) + sed -i'.bak' "$1" "${_args}" + for file in ${_args}; do rm "${file}.bak" done } -function get_version_name() { - echo $(grep "version = " $1 | xargs | cut -d"=" -f2) +get_version_name() { + grep "version = " "$1" | xargs | cut -d"=" -f2 } diff --git a/scripts/publish b/scripts/publish index 4b4138b..4a61d72 100755 --- a/scripts/publish +++ b/scripts/publish @@ -1,6 +1,6 @@ #!/bin/bash # -# Script to publish libary in case a release commit is discovered +# Script to publish library in case a release commit is discovered # SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) diff --git a/scripts/secret b/scripts/secret deleted file mode 100755 index e55acb4..0000000 --- a/scripts/secret +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# -# Script to encrypt / decrypt secrets. -# - -SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -. "${SCRIPT_DIR}/inc.functions.sh" - -# Constants -SECRET_FILES=( - buildSrc/src/main/kotlin/Secrets.kt -) - -# Functions -function usage() { - echo -e "Usage: ${0} [COMMAND]" - echo -e "Options:" - echo -e " --password PASSWORD" - echo -e "Commands:" - echo -e " decrypt" - echo -e " encrypt" - exit 1 -} - -# Command-line arguments -password= -command= -files=("${SECRET_FILES[@]}") -while [[ $# -gt 0 ]]; do - key="$1" - case ${key} in - decrypt) - command=decrypt - ;; - encrypt) - command=encrypt - ;; - -p | --password) - password="--passphrase $2" - shift # past argument - ;; - -h | --help) - usage - ;; - *) - warn "Unknown option: ${key}" - usage - ;; - esac - shift # past argument or value -done - -# Checks -[[ -n "${command}" ]] || usage - -# Let's roll -case ${command} in -decrypt) - for file in "${files[@]}"; do - approve "Decrypting ${file}.enc" - safe gpg --batch --yes ${password} --output "${file}" --decrypt "${file}.gpg" - if [[ "$(file -b "${file}")" == "data" ]]; then - rm -f "${file}" - die "Failed to decrypt ${file}" - fi - done - ;; -encrypt) - for file in "${files[@]}"; do - approve "Encrypting ${file}" - safe gpg --batch --yes ${password} --output "${file}.gpg" --symmetric "${file}" - done - ;; -esac