Skip to content

Commit

Permalink
feat: add support for specifying sub interface in component map signa…
Browse files Browse the repository at this point in the history
…ture
  • Loading branch information
Idane committed Jul 6, 2024
1 parent af879ef commit 22d7437
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 159 deletions.
59 changes: 0 additions & 59 deletions .circleci/config.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish

on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Install Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_GPG_SECRET_KEY_BASE64: ${{ secrets.OSSRH_GPG_SECRET_KEY_BASE64 }}
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
export RELEASE_VERSION=${{ github.event.number }}-PR-SNAPSHOT
echo "Deploying version $RELEASE_VERSION"
./gradlew -Prelease jar publishToSonatype
else
if [ "${{ github.ref_type }}" = "tag" ]; then
export RELEASE_VERSION=${{ github.ref_name }}
export RELEASE_VERSION=${RELEASE_VERSION:1}
else
export RELEASE_VERSION=${{ github.sha }}-SNAPSHOT
fi
echo "Deploying version $RELEASE_VERSION"
./gradlew -Prelease jar publishToSonatype closeAndReleaseSonatypeStagingRepository
fi
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release
on:
push:
branches:
- master
- beta

permissions:
contents: read # for checkout

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.CLONE_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.CLONE_TOKEN }}
run: npx semantic-release
44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test

on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Install Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew test --info
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: success() || failure()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
7 changes: 7 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
105 changes: 53 additions & 52 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,53 +1,63 @@
import org.jetbrains.dokka.gradle.DokkaTask
import java.util.*

plugins {
`java-library`
`maven-publish`
signing
jacoco
id("org.jetbrains.dokka") version "1.6.0"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}

if (hasProperty("release")) {
subprojects {
apply(plugin = "java-library")
apply(plugin = "signing")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
group = "dev.krud"
version = extra["spring-componentmap.version"] ?: error("spring-componentmap.version is not set")
java.sourceCompatibility = JavaVersion.VERSION_1_8
val isSnapshot = version.toString().endsWith("-SNAPSHOT")
val repoUri = if (isSnapshot) {
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val ossrhUsername = System.getenv("OSSRH_USERNAME")
val ossrhPassword = System.getenv("OSSRH_PASSWORD")
val releaseVersion = System.getenv("RELEASE_VERSION")
group = "dev.krud"
version = releaseVersion
nexusPublishing {
this@nexusPublishing.repositories {
sonatype {
username.set(ossrhUsername)
password.set(ossrhPassword)
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
}

if (!isSnapshot) {
java {
withJavadocJar()
withSourcesJar()
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")

if (hasProperty("release")) {
val releaseVersion = System.getenv("RELEASE_VERSION")
val signingKeyBase64 = System.getenv("OSSRH_GPG_SECRET_KEY_BASE64")
val signingPassword = System.getenv("OSSRH_GPG_SECRET_KEY_PASSWORD")
group = "dev.krud"
version = releaseVersion
val isSnapshot = version.toString().endsWith("-SNAPSHOT")
java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
repositories {
maven {
name = "OSSRH"
url = uri(repoUri)
credentials {
username = System.getenv("OSSRH_USERNAME") ?: extra["ossrh.username"]?.toString()
password = System.getenv("OSSRH_PASSWORD") ?: extra["ossrh.password"]?.toString()
}
}
}
artifactId = project.name

pom {
name.set(this@subprojects.name)
name.set(project.name)
description.set("A Kotlin library for intelligent object mapping.")
url.set("https://github.com/krud-dev/spring-componentmap")
url.set("https://github.com/krud-dev/shapeshift/shapeshift")
licenses {
license {
name.set("MIT License")
Expand All @@ -73,31 +83,22 @@ if (hasProperty("release")) {
}
}

if (!isSnapshot) {
val javadocTask = tasks.named<Javadoc>("javadoc").get()

tasks.withType<DokkaTask> {
javadocTask.dependsOn(this)
outputDirectory.set(javadocTask.destinationDir)
}
val javadocTask = tasks.named<Javadoc>("javadoc").get()

signing {
sign(publishing.publications["maven"])
}
tasks.withType<DokkaTask> {
javadocTask.dependsOn(this)
outputDirectory.set(javadocTask.destinationDir)
}
signing {
val signingKey = signingKeyBase64?.let { decodeBase64(it) }
useInMemoryPgpKeys(
signingKey, signingPassword
)
sign(publishing.publications["maven"])
}
}
}

subprojects {
apply(plugin = "jacoco")
tasks.withType<Test> {
finalizedBy(tasks.withType<JacocoReport>())
}
tasks.withType<JacocoReport> {
dependsOn(tasks.test)
reports {
xml.required.set(true)
html.required.set(false)
}
}
fun decodeBase64(base64: String): String {
return String(Base64.getDecoder().decode(base64))
}
Loading

0 comments on commit 22d7437

Please sign in to comment.