Skip to content

Commit

Permalink
Merge pull request #43 from samtkit/publish-to-maven
Browse files Browse the repository at this point in the history
Publish to maven
  • Loading branch information
PascalHonegger authored Jun 2, 2023
2 parents deb15c9 + 8af265a commit 4e3edb6
Show file tree
Hide file tree
Showing 37 changed files with 195 additions and 68 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ jobs:

- name: Rename cli-shadow to cli
run: |
mv cli/build/distributions/cli-shadow.zip cli/build/distributions/cli.zip
mv cli/build/distributions/cli-shadow.tar cli/build/distributions/cli.tar
mv cli/build/distributions/cli-shadow-*.zip cli/build/distributions/cli.zip
mv cli/build/distributions/cli-shadow-*.tar cli/build/distributions/cli.tar
- name: Release
- name: Rename samt-ls-version to samt-ls
run: |
mv language-server/build/libs/samt-ls-*.jar language-server/build/libs/samt-ls.jar
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
Expand All @@ -36,3 +40,11 @@ jobs:
fail_on_unmatched_files: true
draft: true
generate_release_notes: true

- name: Publish to Sonatype OSSRH
run: ./gradlew --no-daemon publishMavenPublicationToOSSRHRepository
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SECRET }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PGP_PASSWORD }}
22 changes: 22 additions & 0 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish Snapshot
on:
push:
branches: [main]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Publish Snapshot to Sonatype OSSRH
run: ./gradlew --no-daemon publishMavenPublicationToOSSRHRepository
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
17 changes: 14 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
alias(libs.plugins.kover)
alias(libs.plugins.versioning)
}

repositories {
Expand All @@ -8,9 +9,7 @@ repositories {

dependencies {
kover(project(":common"))
kover(project(":lexer"))
kover(project(":parser"))
kover(project(":semantic"))
kover(project(":compiler"))
kover(project(":cli"))
kover(project(":language-server"))
kover(project(":samt-config"))
Expand All @@ -28,3 +27,15 @@ koverReport {
}
}
}

version = "0.0.0-SNAPSHOT"
gitVersioning.apply {
refs {
branch(".+") {
version = "\${ref}-SNAPSHOT"
}
tag("v(?<version>.*)") {
version = "\${ref.version}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ repositories {
mavenCentral()
}

group = "samt-core"
group = "tools.samt"
76 changes: 76 additions & 0 deletions buildSrc/src/main/kotlin/samt-core.library.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
plugins {
id("samt-core.kotlin-jvm")
`java-library`
`maven-publish`
signing
}

val mavenName: String by project.extra
val mavenDescription: String by project.extra

publishing {
publications {
create<MavenPublication>("maven") {
pom {
name.set(provider { mavenName })
description.set(provider { mavenDescription })
url.set("https://github.com/samtkit/core")
licenses {
license {
name.set("MIT License")
url.set("https://github.com/samtkit/core/blob/main/LICENSE")
}
}
developers {
developer {
name.set("Pascal Honegger")
email.set("[email protected]")
organization.set("Simple API Modeling Toolkit")
organizationUrl.set("https://github.com/samtkit")
}
developer {
name.set("Marcel Joss")
email.set("[email protected]")
organization.set("Simple API Modeling Toolkit")
organizationUrl.set("https://github.com/samtkit")
}
developer {
name.set("Leonard Schütz")
email.set("[email protected]")
organization.set("Simple API Modeling Toolkit")
organizationUrl.set("https://github.com/samtkit")
}
}
scm {
connection.set("scm:git:git://github.com/samtkit/core.git")
developerConnection.set("scm:git:ssh://github.com/samtkit/core.git")
url.set("https://github.com/samtkit/core")
}
}
from(components["java"])
}
}

repositories {
maven {
name = "OSSRH"
url = if (version.toString().endsWith("-SNAPSHOT")) {
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
} else {
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
}
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}

signing {
isRequired = !version.toString().endsWith("-SNAPSHOT")
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["maven"])
}
7 changes: 2 additions & 5 deletions cli/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
application
id("samt-core.kotlin-conventions")
id("samt-core.kotlin-jvm")
alias(libs.plugins.shadow)
kotlin("plugin.serialization")
alias(libs.plugins.kover)
Expand All @@ -11,12 +11,9 @@ dependencies {
implementation(libs.mordant)
implementation(libs.kotlinx.serialization.json)
implementation(project(":common"))
implementation(project(":lexer"))
implementation(project(":parser"))
implementation(project(":semantic"))
implementation(project(":compiler"))
implementation(project(":samt-config"))
implementation(project(":codegen"))
implementation(project(":public-api"))
}

application {
Expand Down
12 changes: 7 additions & 5 deletions codegen/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
plugins {
id("samt-core.kotlin-conventions")
id("samt-core.kotlin-jvm")
id("samt-core.library")
alias(libs.plugins.kover)
}

val mavenName: String by extra("SAMT CodeGen")
val mavenDescription: String by extra("Call SAMT plugins to generate code from SAMT files.")

dependencies {
implementation(project(":common"))
implementation(project(":parser"))
implementation(project(":semantic"))
implementation(project(":public-api"))
testImplementation(project(":lexer"))
implementation(project(":compiler"))
api(project(":public-api"))
testImplementation(project(":samt-config"))
}
19 changes: 12 additions & 7 deletions codegen/src/main/kotlin/tools/samt/codegen/http/HttpTransport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,27 @@ object HttpTransportConfigurationParser : TransportConfigurationParser {
// and can generate default configurations for operations that have no explicit configuration.

// check for duplicate method/path combinations within current service
for (operation in parsedOperations) {
if (operation.path == path && operation.method == methodEnum) {
val duplicate = operation
params.reportError("Operation '${serviceName}.${operationName}' cannot be mapped to the same method and path combination ($method $servicePath$path) as operation '${serviceName}.${duplicate.name}'", operationConfig)
for (parsedOperation in parsedOperations) {
if (parsedOperation.path == path && parsedOperation.method == methodEnum) {
params.reportError(
"Operation '${serviceName}.${operationName}' cannot be mapped to the same method and path combination ($method $servicePath$path) as operation '${serviceName}.${parsedOperation.name}'",
operationConfig
)
continue@operationConfigLoop
}
}

// check for duplicate method/path combinations within previously declared services
for (service in parsedServices.filter { it.path == servicePath }) {
val duplicate = service.operations.find { op ->
for (parsedService in parsedServices.filter { it.path == servicePath }) {
val duplicate = parsedService.operations.find { op ->
op.path == path && op.method == methodEnum
}

if (duplicate != null) {
params.reportError("Operation '${serviceName}.${operationName}' cannot be mapped to the same method and path combination ($method ${service.path}$path) as operation '${service.name}.${duplicate.name}'", operationConfig)
params.reportError(
"Operation '${serviceName}.${operationName}' cannot be mapped to the same method and path combination ($method ${parsedService.path}$path) as operation '${parsedService.name}.${duplicate.name}'",
operationConfig
)
continue@operationConfigLoop
}
}
Expand Down
6 changes: 5 additions & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
plugins {
id("samt-core.kotlin-conventions")
id("samt-core.kotlin-jvm")
id("samt-core.library")
alias(libs.plugins.kover)
}

val mavenName: String by extra("SAMT Common")
val mavenDescription: String by extra("Common SAMT module")
13 changes: 13 additions & 0 deletions compiler/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
id("samt-core.kotlin-jvm")
id("samt-core.library")
alias(libs.plugins.kover)
}

val mavenName: String by extra("SAMT Compiler")
val mavenDescription: String by extra("Parse, analyze, and do whatever you desire with SAMT files.")

dependencies {
implementation(kotlin("reflect"))
implementation(project(":common"))
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tools.samt.lexer

import tools.samt.common.*
import tools.samt.common.DiagnosticContext
import tools.samt.common.FileOffset
import tools.samt.common.Location
import java.io.BufferedReader
import java.io.Reader

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tools.samt.semantic

import tools.samt.parser.*
import tools.samt.parser.BundleIdentifierNode
import tools.samt.parser.IdentifierNode
import tools.samt.parser.Node

class Package(val name: String, private val parent: Package?) {
val subPackages: MutableList<Package> = mutableListOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ internal class SemanticModelBuilder(
filePackage.sourcePackage.linkType(import, type)

val name = if (import.alias != null) {
import.alias!!.name
import.alias.name
} else {
import.name.components.last().name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package tools.samt.parser

import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.assertThrows
import tools.samt.common.*
import tools.samt.common.DiagnosticContext
import tools.samt.common.DiagnosticController
import tools.samt.common.DiagnosticException
import tools.samt.common.SourceFile
import tools.samt.lexer.Lexer
import java.net.URI
import kotlin.test.Test
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.configuration-cache=true
# Breaks with the current version of the gradle versioning plugin
# org.gradle.configuration-cache=true
6 changes: 2 additions & 4 deletions language-server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
application
id("samt-core.kotlin-conventions")
id("samt-core.kotlin-jvm")
alias(libs.plugins.shadow)
alias(libs.plugins.kover)
}
Expand All @@ -9,9 +9,7 @@ dependencies {
implementation(libs.jCommander)
implementation(libs.lsp4j)
implementation(project(":common"))
implementation(project(":lexer"))
implementation(project(":parser"))
implementation(project(":semantic"))
implementation(project(":compiler"))
implementation(project(":samt-config"))
}

Expand Down
9 changes: 0 additions & 9 deletions lexer/build.gradle.kts

This file was deleted.

10 changes: 0 additions & 10 deletions parser/build.gradle.kts

This file was deleted.

6 changes: 5 additions & 1 deletion public-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("samt-core.kotlin-conventions")
id("samt-core.kotlin-jvm")
id("samt-core.library")
}

val mavenName: String by extra("SAMT Public API")
val mavenDescription: String by extra("Public API for creating custom SAMT plugins.")
6 changes: 5 additions & 1 deletion samt-config/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
plugins {
id("samt-core.kotlin-conventions")
id("samt-core.kotlin-jvm")
id("samt-core.library")
alias(libs.plugins.kover)
}

val mavenName: String by extra("SAMT Config")
val mavenDescription: String by extra("SAMT Configuration Parser")

dependencies {
implementation(project(":common"))
implementation(libs.kotlinx.serialization.yaml)
Expand Down
10 changes: 0 additions & 10 deletions semantic/build.gradle.kts

This file was deleted.

Loading

0 comments on commit 4e3edb6

Please sign in to comment.