From d8d3651277caee6925a2c2fcc600db541102aea8 Mon Sep 17 00:00:00 2001 From: Christian Ingenhaag Date: Fri, 16 Feb 2024 16:00:06 +0100 Subject: [PATCH] chore: Introduce maven publishing --- .github/dependabot.yml | 10 +++ .github/workflows/gradle-build.yml | 26 ++++++++ .github/workflows/gradle-publish.yml | 33 ++++++++++ .github/workflows/gradle-test.yml | 43 +++++++++++++ CODEOWNERS | 4 +- build.gradle | 30 --------- gradle.properties | 2 + horizon-core/build.gradle | 64 ++++++++++++++++++- .../eni/pandora/horizon/model/db/State.java | 2 + .../build.gradle | 63 +++++++++++++++++- horizon-spring-boot-starter/build.gradle | 62 +++++++++++++++++- 11 files changed, 298 insertions(+), 41 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/gradle-build.yml create mode 100644 .github/workflows/gradle-publish.yml create mode 100644 .github/workflows/gradle-test.yml delete mode 100755 build.gradle diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..27bdbc3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2024 Deutsche Telekom AG +# +# SPDX-License-Identifier: Apache-2.0 + +version: 2 +updates: + - package-ecosystem: "gradle" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml new file mode 100644 index 0000000..83e7f77 --- /dev/null +++ b/.github/workflows/gradle-build.yml @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2024 Deutsche Telekom AG +# +# SPDX-License-Identifier: Apache-2.0 + +name: Gradle Build +on: push +jobs: + gradle: + runs-on: ubuntu-latest + + services: + docker: + image: docker:25-dind + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Execute Gradle build + run: ./gradlew build \ No newline at end of file diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml new file mode 100644 index 0000000..69a1fac --- /dev/null +++ b/.github/workflows/gradle-publish.yml @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2024 Deutsche Telekom AG +# +# SPDX-License-Identifier: Apache-2.0 + +name: Gradle Publish +on: + release: + types: [published] +jobs: + gradle: + runs-on: ubuntu-latest + + services: + docker: + image: docker:25-dind + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Execute Gradle publish + env: + PUBLISH_USERNAME: ${{ secrets.PUBLISH_USERNAME }} + PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }} + PUBLISH_GPG_PRIVATE_KEY: ${{ secrets.PUBLISH_GPG_PRIVATE_KEY }} + PUBLISH_GPG_PASSPHRASE: ${{ secrets.PUBLISH_GPG_PASSPHRASE }} + run: ./gradlew -Pversion=${{ github.event.release.name }} publish diff --git a/.github/workflows/gradle-test.yml b/.github/workflows/gradle-test.yml new file mode 100644 index 0000000..5badd5b --- /dev/null +++ b/.github/workflows/gradle-test.yml @@ -0,0 +1,43 @@ +# SPDX-FileCopyrightText: 2024 Deutsche Telekom AG +# +# SPDX-License-Identifier: Apache-2.0 + +name: Gradle Test +on: + push: + pull_request: + branches: + - main +jobs: + gradle: + runs-on: ubuntu-latest + + services: + docker: + image: docker:25-dind + + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Execute Gradle build + run: ./gradlew test + + - name: Add coverage to PR + id: jacoco + uses: madrapps/jacoco-report@v1.6.1 + with: + paths: | + ${{ github.workspace }}/**/build/reports/jacoco/**/jacocoTestReport.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: 60 + min-coverage-changed-files: 80 + if: github.event_name == 'pull_request' \ No newline at end of file diff --git a/CODEOWNERS b/CODEOWNERS index 574fe89..e5ccb28 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -2,5 +2,5 @@ # # SPDX-License-Identifier: Apache-2.0 -[Development][1] @dhei/teams/pandora/pandora-internal -* \ No newline at end of file +# Pubsub-horizon-spring-parent is currently maintained by Telekom's Horizon team. +* @telekom/pubsub-horizon \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100755 index 3565d8b..0000000 --- a/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2024 Deutsche Telekom IT GmbH -// -// SPDX-License-Identifier: Apache-2.0 - -def getVersion() { - def version = "0.0.0" - def gitBranch = "develop" - try { - def workingDir = new File("${project.projectDir}") - def result = 'git rev-parse --abbrev-ref HEAD'.execute(null, workingDir) - result.waitFor() - if (result.exitValue() == 0) { - gitBranch = result.text.trim().replace("/", "-") - } - } catch (ignored) {} - - if (System.getenv('CI_COMMIT_TAG')) { - version = System.getenv('CI_COMMIT_TAG') - } else if (System.getenv('CI_COMMIT_REF_SLUG')) { - version += ("-" + System.getenv('CI_COMMIT_REF_SLUG')) - } else { - version += ("-" + gitBranch) - } - - return version -} - -ext { - parentVersion = getVersion() -} diff --git a/gradle.properties b/gradle.properties index 830eb19..c890aad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,3 +10,5 @@ hazelcastVersion=4.2.8 # internal jsonFilterVersion=1.0.1 + +version=0.0.0-DEVELOPMENT diff --git a/horizon-core/build.gradle b/horizon-core/build.gradle index a6dd229..ff5d3ee 100755 --- a/horizon-core/build.gradle +++ b/horizon-core/build.gradle @@ -10,14 +10,16 @@ plugins { id 'io.spring.dependency-management' id 'maven-publish' id 'jacoco' + id 'signing' } group 'de.telekom.eni' -version "${parentVersion}" java { sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 + withJavadocJar() + withSourcesJar() } dependencyManagement { @@ -73,15 +75,57 @@ dependencies { publishing { publications { - mavenPublication(MavenPublication) { + + mavenJava(MavenPublication) { + from components.java groupId 'de.telekom.eni' artifactId 'horizon-core' - version project.version + version = project.properties['version'] + + pom { + name = 'Horizon spring parent core' + description = 'A simple library that allows for filtering JSON documents.' + url = 'https://github.com/telekom/pubsub-horizon-spring-parent' + inceptionYear = '2022' + + licenses { + license { + name = 'Apache-2.0' + url = 'https://opensource.org/licenses/Apache-2.0' + } + } + developers { + developer { + id = 'eni-pandora' + name = 'Team Pandora' + email = 'dtit_eni_hub_team_pandora@telekom.de' + organization = 'Deutsche Telekom IT GmbH' + organizationUrl = 'https://developer.telekom.de/' + } + } + scm { + connection = 'scm:git:git://github.com/telekom/pubsub-horizon-spring-parent.git' + developerConnection = 'scm:git:git://github.com/telekom/pubsub-horizon-spring-parent.git' + url = 'https://github.com/telekom/pubsub-horizon-spring-parent' + } + } + } + } + + repositories { + maven { + name = "OSSRH" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username = System.getenv('PUBLISH_USERNAME') + password = System.getenv('PUBLISH_PASSWORD') + } } } } + test { finalizedBy jacocoTestReport } @@ -96,4 +140,18 @@ jacocoTestReport { test { useJUnitPlatform() +} + +signing { + def signingKey = new String(Base64.decoder.decode(System.getenv('PUBLISH_GPG_PRIVATE_KEY') ?: "")) + def signingPassword = System.getenv('PUBLISH_GPG_PASSPHRASE') + useInMemoryPgpKeys(signingKey, signingPassword) + + sign publishing.publications.mavenJava +} + +javadoc { + if (JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } } \ No newline at end of file diff --git a/horizon-core/src/main/java/de/telekom/eni/pandora/horizon/model/db/State.java b/horizon-core/src/main/java/de/telekom/eni/pandora/horizon/model/db/State.java index 16be5b4..ac9279a 100644 --- a/horizon-core/src/main/java/de/telekom/eni/pandora/horizon/model/db/State.java +++ b/horizon-core/src/main/java/de/telekom/eni/pandora/horizon/model/db/State.java @@ -102,4 +102,6 @@ public static StateBuilder builder(Status status, EventMessage message, Evaluati return builder; } + public static class StateBuilder {} + } diff --git a/horizon-spring-boot-autoconfigure/build.gradle b/horizon-spring-boot-autoconfigure/build.gradle index 209f39b..6e6c163 100755 --- a/horizon-spring-boot-autoconfigure/build.gradle +++ b/horizon-spring-boot-autoconfigure/build.gradle @@ -10,14 +10,16 @@ plugins { id 'io.spring.dependency-management' id 'maven-publish' id 'jacoco' + id 'signing' } group 'de.telekom.eni' -version "${parentVersion}" java { sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 + withJavadocJar() + withSourcesJar() } dependencyManagement { @@ -46,11 +48,52 @@ dependencies { publishing { publications { - mavenPublication(MavenPublication) { + + mavenJava(MavenPublication) { + from components.java groupId 'de.telekom.eni' artifactId 'horizon-spring-boot-autoconfigure' - version project.version + version = project.properties['version'] + + pom { + name = 'Horizon spring parent autoconfigure' + description = 'A simple library that allows for filtering JSON documents.' + url = 'https://github.com/telekom/pubsub-horizon-spring-parent' + inceptionYear = '2022' + + licenses { + license { + name = 'Apache-2.0' + url = 'https://opensource.org/licenses/Apache-2.0' + } + } + developers { + developer { + id = 'eni-pandora' + name = 'Team Pandora' + email = 'dtit_eni_hub_team_pandora@telekom.de' + organization = 'Deutsche Telekom IT GmbH' + organizationUrl = 'https://developer.telekom.de/' + } + } + scm { + connection = 'scm:git:git://github.com/telekom/pubsub-horizon-spring-parent.git' + developerConnection = 'scm:git:git://github.com/telekom/pubsub-horizon-spring-parent.git' + url = 'https://github.com/telekom/pubsub-horizon-spring-parent' + } + } + } + } + + repositories { + maven { + name = "OSSRH" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username = System.getenv('PUBLISH_USERNAME') + password = System.getenv('PUBLISH_PASSWORD') + } } } } @@ -66,3 +109,17 @@ jacocoTestReport { html.required = true } } + +signing { + def signingKey = new String(Base64.decoder.decode(System.getenv('PUBLISH_GPG_PRIVATE_KEY') ?: "")) + def signingPassword = System.getenv('PUBLISH_GPG_PASSPHRASE') + useInMemoryPgpKeys(signingKey, signingPassword) + + sign publishing.publications.mavenJava +} + +javadoc { + if (JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } +} diff --git a/horizon-spring-boot-starter/build.gradle b/horizon-spring-boot-starter/build.gradle index 6db2248..0d20c43 100755 --- a/horizon-spring-boot-starter/build.gradle +++ b/horizon-spring-boot-starter/build.gradle @@ -10,14 +10,16 @@ plugins { id 'io.spring.dependency-management' id 'maven-publish' id 'jacoco' + id 'signing' } group 'de.telekom.eni' -version "${parentVersion}" java { sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 + withJavadocJar() + withSourcesJar() } dependencyManagement { @@ -38,13 +40,53 @@ dependencies { publishing { publications { - mavenPublication(MavenPublication) { + mavenJava(MavenPublication) { from components.java groupId 'de.telekom.eni' artifactId 'horizon-spring-boot-starter' - version project.version + version = project.properties['version'] + + pom { + name = 'Horizon spring parent starter' + description = 'A simple library that allows for filtering JSON documents.' + url = 'https://github.com/telekom/pubsub-horizon-spring-parent' + inceptionYear = '2022' + + licenses { + license { + name = 'Apache-2.0' + url = 'https://opensource.org/licenses/Apache-2.0' + } + } + developers { + developer { + id = 'eni-pandora' + name = 'Team Pandora' + email = 'dtit_eni_hub_team_pandora@telekom.de' + organization = 'Deutsche Telekom IT GmbH' + organizationUrl = 'https://developer.telekom.de/' + } + } + scm { + connection = 'scm:git:git://github.com/telekom/pubsub-horizon-spring-parent.git' + developerConnection = 'scm:git:git://github.com/telekom/pubsub-horizon-spring-parent.git' + url = 'https://github.com/telekom/pubsub-horizon-spring-parent' + } + } + } + } + + repositories { + maven { + name = "OSSRH" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username = System.getenv('PUBLISH_USERNAME') + password = System.getenv('PUBLISH_PASSWORD') + } } } + } test { @@ -59,3 +101,17 @@ jacocoTestReport { html.required = true } } + +signing { + def signingKey = new String(Base64.decoder.decode(System.getenv('PUBLISH_GPG_PRIVATE_KEY') ?: "")) + def signingPassword = System.getenv('PUBLISH_GPG_PASSPHRASE') + useInMemoryPgpKeys(signingKey, signingPassword) + + sign publishing.publications.mavenJava +} + +javadoc { + if (JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } +} \ No newline at end of file