Skip to content

Commit

Permalink
Add Maven Central release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Thijsiez committed Nov 8, 2024
1 parent 50e547c commit 0fc844d
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 97 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: release

on:
push:
tags:
- "*.*.*"

jobs:
release:
name: Release main to Maven Central
runs-on: ubuntu-latest
if: github.repository == 'Thijsiez/panache-kotlin-dsl'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- run: chmod +x gradlew
- env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publishToMavenCentral --no-configuration-cache --no-daemon
- uses: softprops/action-gh-release@v2
18 changes: 8 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ name: test
on: [push, workflow_dispatch]

jobs:
build:
name: test
test:
name: Run tests and publish report to SonarQube
runs-on: ubuntu-latest
permissions: read-all
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Run tests with Gradle wrapper
env:
- run: cd examples && chmod +x gradlew
- run: ./gradlew koverXmlReport --no-daemon --continue
- env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: cd examples && chmod +x gradlew && ./gradlew koverXmlReport sonar --no-daemon --continue --info
run: ./gradlew sonar --no-daemon --info
38 changes: 7 additions & 31 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import com.vanniktech.maven.publish.SonatypeHost

plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
id("org.jetbrains.kotlinx.kover")
id("com.vanniktech.maven.publish")
}

val groupId: String by project
setGroup(groupId)
val artifactId: String by project
val version: String by project
setVersion(version)

Expand All @@ -44,7 +44,10 @@ dependencies {
implementation("com.google.devtools.ksp:symbol-processing-api:$kspVersion")
implementation("com.squareup:kotlinpoet-ksp:$kotlinPoetVersion")

testImplementation("io.quarkus:quarkus-junit5")
testImplementation("io.quarkus:quarkus-junit5") {
//Because of https://osv.dev/vulnerability/GHSA-hfq9-hggm-c56q, unused anyway
exclude(group = "com.thoughtworks.xstream", module = "xstream")
}
testImplementation("io.mockk:mockk:$mockkVersion")
testImplementation("com.github.tschuchortdev:kotlin-compile-testing-ksp:$compileTestingVersion")
}
Expand All @@ -57,36 +60,9 @@ kotlin {
jvmToolchain(17)
}
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, false)
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = false)
signAllPublications()

coordinates(groupId, artifactId, version)
pom {
name = artifactId
description = "A dynamic, type-safe way to write your queries"
url = "https://icken.ch/panache-kotlin-dsl"

licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}

developers {
developer {
id = "Thijsiez"
name = "Thijs Koppen"
email = "[email protected]"
}
}

scm {
url = "https://github.com/Thijsiez/panache-kotlin-dsl"
connection = "scm:git:https://github.com/Thijsiez/panache-kotlin-dsl"
developerConnection = "scm:git:https://github.com/Thijsiez/panache-kotlin-dsl"
}
}
coordinates(groupId, rootProject.name, version)
}

tasks {
Expand Down
27 changes: 27 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,30 @@
# limitations under the License.
#

#region POM
groupId=ch.icken
artifactId=panache-kotlin-dsl
version=0.0.3

POM_NAME=Panache Kotlin DSL
POM_DESCRIPTION=A dynamic, type-safe way to write your queries
POM_URL=https://github.com/Thijsiez/panache-kotlin-dsl

POM_LICENSE_NAME=The Apache Software License, Version 2.0
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo

POM_SCM_URL=https://github.com/Thijsiez/panache-kotlin-dsl
POM_SCM_CONNECTION=scm:git:https://github.com/Thijsiez/panache-kotlin-dsl
POM_SCM_DEV_CONNECTION=scm:git:https://github.com/Thijsiez/panache-kotlin-dsl

POM_DEVELOPER_ID=Thijsiez
POM_DEVELOPER_NAME=Thijs Koppen
POM_DEVELOPER_EMAIL=[email protected]
POM_DEVELOPER_URL=https://github.com/Thijsiez
#endregion

#region Dependencies
#https://github.com/quarkusio/quarkus Pinned, do not change
# Minimum, because of https://osv.dev/vulnerability/GHSA-f8h5-v2vg-46rr
# Does not need to be upgraded since we only use the Panache API
Expand All @@ -42,10 +62,17 @@ mockkVersion=1.13.11

#https://github.com/tschuchortdev/kotlin-compile-testing
compileTestingVersion=1.6.0
#endregion

#region Plugins
#https://github.com/Kotlin/dokka
dokkaVersion=1.9.20

#https://github.com/Kotlin/kotlinx-kover
koverVersion=0.8.3

#https://github.com/vanniktech/gradle-maven-publish-plugin
mavenPublishVersion=0.30.0
#endregion

kotlin.code.style=official
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ pluginManagement {

plugins {
val kotlinVersion: String by settings
val dokkaVersion: String by settings
val koverVersion: String by settings
val mavenPublishVersion: String by settings

kotlin("jvm") version kotlinVersion
id("org.jetbrains.dokka") version dokkaVersion
id("org.jetbrains.kotlinx.kover") version koverVersion
id("com.vanniktech.maven.publish") version mavenPublishVersion
}
Expand Down
112 changes: 56 additions & 56 deletions src/main/kotlin/ch/icken/processor/ProcessorCommon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,68 +56,68 @@ abstract class ProcessorCommon(options: Map<String, String>) {

companion object {
//region Class Names
val ColumnClassName = Column::class.asClassName()
val ExpressionClassName = Expression::class.asClassName()
val GeneratedClassName = Generated::class.asClassName()
val JvmNameClassName = JvmName::class.asClassName()
val ListClassName = List::class.asClassName()
val LongClassName = Long::class.asClassName()
val PanacheQueryClassName = PanacheQuery::class.asClassName()
val PanacheSingleResultClassName = PanacheSingleResult::class.asClassName()
val QueryComponentClassName = QueryComponent::class.asClassName()
val SetterClassName = UpdateComponent.InitialUpdateComponent.Setter::class.asClassName()
val SortClassName = Sort::class.asClassName()
val StreamClassName = Stream::class.asClassName()
val StringClassName = String::class.asClassName()
val SuppressClassName = Suppress::class.asClassName()
val UpdateComponentClassName = UpdateComponent::class.asClassName()
internal val ColumnClassName = Column::class.asClassName()
internal val ExpressionClassName = Expression::class.asClassName()
internal val GeneratedClassName = Generated::class.asClassName()
internal val JvmNameClassName = JvmName::class.asClassName()
internal val ListClassName = List::class.asClassName()
internal val LongClassName = Long::class.asClassName()
internal val PanacheQueryClassName = PanacheQuery::class.asClassName()
internal val PanacheSingleResultClassName = PanacheSingleResult::class.asClassName()
internal val QueryComponentClassName = QueryComponent::class.asClassName()
internal val SetterClassName = UpdateComponent.InitialUpdateComponent.Setter::class.asClassName()
internal val SortClassName = Sort::class.asClassName()
internal val StreamClassName = Stream::class.asClassName()
internal val StringClassName = String::class.asClassName()
internal val SuppressClassName = Suppress::class.asClassName()
internal val UpdateComponentClassName = UpdateComponent::class.asClassName()
//endregion
//region Constants
const val CLASS_NAME_COMPANION = "Companion"
const val FUNCTION_NAME_AND = "and"
const val FUNCTION_NAME_AND_EXPRESSION = "andExpression"
const val FUNCTION_NAME_COUNT = "count"
const val FUNCTION_NAME_DELETE = "delete"
const val FUNCTION_NAME_FIND = "find"
const val FUNCTION_NAME_FIND_SORTED = "findSorted"
const val FUNCTION_NAME_MULTIPLE = "multiple"
const val FUNCTION_NAME_MULTIPLE_SORTED = "multipleSorted"
const val FUNCTION_NAME_OR = "or"
const val FUNCTION_NAME_OR_EXPRESSION = "orExpression"
const val FUNCTION_NAME_SINGLE = "single"
const val FUNCTION_NAME_SINGLE_SAFE = "singleSafe"
const val FUNCTION_NAME_STREAM = "stream"
const val FUNCTION_NAME_STREAM_SORTED = "streamSorted"
const val FUNCTION_NAME_UPDATE = "update"
const val FUNCTION_NAME_UPDATE_MULTIPLE = "updateMultiple"
const val FUNCTION_NAME_WHERE = "where"
const val PARAM_NAME_COLUMNS_BASE_CLASS = "parent"
const val PARAM_NAME_EXPRESSION = "expression"
const val PARAM_NAME_MAPPED_BY = "mappedBy"
const val PARAM_NAME_SETTER = "setter"
const val PARAM_NAME_SETTERS = "setters"
const val PARAM_NAME_SORT = "sort"
const val PARAM_NAME_TYPE = "type"
const val SUFFIX_CLASS_COLUMNS_BASE = "Base"
const val SUFFIX_FILE_EXTENSIONS = "Extensions"
const val SUFFIX_OBJECT_COLUMNS = "Columns"
const val SUFFIX_PACKAGE_GENERATED = ".generated"
const val TYPE_VARIABLE_NAME_COLUMNS = "Columns"
internal const val CLASS_NAME_COMPANION = "Companion"
internal const val FUNCTION_NAME_AND = "and"
internal const val FUNCTION_NAME_AND_EXPRESSION = "andExpression"
internal const val FUNCTION_NAME_COUNT = "count"
internal const val FUNCTION_NAME_DELETE = "delete"
internal const val FUNCTION_NAME_FIND = "find"
internal const val FUNCTION_NAME_FIND_SORTED = "findSorted"
internal const val FUNCTION_NAME_MULTIPLE = "multiple"
internal const val FUNCTION_NAME_MULTIPLE_SORTED = "multipleSorted"
internal const val FUNCTION_NAME_OR = "or"
internal const val FUNCTION_NAME_OR_EXPRESSION = "orExpression"
internal const val FUNCTION_NAME_SINGLE = "single"
internal const val FUNCTION_NAME_SINGLE_SAFE = "singleSafe"
internal const val FUNCTION_NAME_STREAM = "stream"
internal const val FUNCTION_NAME_STREAM_SORTED = "streamSorted"
internal const val FUNCTION_NAME_UPDATE = "update"
internal const val FUNCTION_NAME_UPDATE_MULTIPLE = "updateMultiple"
internal const val FUNCTION_NAME_WHERE = "where"
internal const val PARAM_NAME_COLUMNS_BASE_CLASS = "parent"
internal const val PARAM_NAME_EXPRESSION = "expression"
internal const val PARAM_NAME_MAPPED_BY = "mappedBy"
internal const val PARAM_NAME_SETTER = "setter"
internal const val PARAM_NAME_SETTERS = "setters"
internal const val PARAM_NAME_SORT = "sort"
internal const val PARAM_NAME_TYPE = "type"
internal const val SUFFIX_CLASS_COLUMNS_BASE = "Base"
internal const val SUFFIX_FILE_EXTENSIONS = "Extensions"
internal const val SUFFIX_OBJECT_COLUMNS = "Columns"
internal const val SUFFIX_PACKAGE_GENERATED = ".generated"
internal const val TYPE_VARIABLE_NAME_COLUMNS = "Columns"
//endregion
//region Names
val HibernatePanacheCompanionBase: String = PanacheCompanionBase::class.java.name
val HibernatePanacheEntityBase: String = PanacheEntityBase::class.java.name
val JakartaPersistenceEntity: String = Entity::class.java.name
val JakartaPersistenceId: String = Id::class.java.name
val JakartaPersistenceJoinColumn: String = JoinColumn::class.java.name
val JakartaPersistenceManyToMany: String = ManyToMany::class.java.name
val JakartaPersistenceOneToMany: String = OneToMany::class.java.name
val JakartaPersistenceOneToOne: String = OneToOne::class.java.name
val JakartaPersistenceTransient: String = Transient::class.java.name
val ProcessorColumnType: String = ColumnType::class.java.name
internal val HibernatePanacheCompanionBase: String = PanacheCompanionBase::class.java.name
internal val HibernatePanacheEntityBase: String = PanacheEntityBase::class.java.name
internal val JakartaPersistenceEntity: String = Entity::class.java.name
internal val JakartaPersistenceId: String = Id::class.java.name
internal val JakartaPersistenceJoinColumn: String = JoinColumn::class.java.name
internal val JakartaPersistenceManyToMany: String = ManyToMany::class.java.name
internal val JakartaPersistenceOneToMany: String = OneToMany::class.java.name
internal val JakartaPersistenceOneToOne: String = OneToOne::class.java.name
internal val JakartaPersistenceTransient: String = Transient::class.java.name
internal val ProcessorColumnType: String = ColumnType::class.java.name
//endregion
//region Options
const val OPTION_ADD_GENERATED_ANNOTATION = "addGeneratedAnnotation"
internal const val OPTION_ADD_GENERATED_ANNOTATION = "addGeneratedAnnotation"
//endregion
}
}

0 comments on commit 0fc844d

Please sign in to comment.