Skip to content

Commit 4e3edb6

Browse files
Merge pull request #43 from samtkit/publish-to-maven
Publish to maven
2 parents deb15c9 + 8af265a commit 4e3edb6

37 files changed

Lines changed: 195 additions & 68 deletions

.github/workflows/publish-release.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ jobs:
2323

2424
- name: Rename cli-shadow to cli
2525
run: |
26-
mv cli/build/distributions/cli-shadow.zip cli/build/distributions/cli.zip
27-
mv cli/build/distributions/cli-shadow.tar cli/build/distributions/cli.tar
26+
mv cli/build/distributions/cli-shadow-*.zip cli/build/distributions/cli.zip
27+
mv cli/build/distributions/cli-shadow-*.tar cli/build/distributions/cli.tar
2828
29-
- name: Release
29+
- name: Rename samt-ls-version to samt-ls
30+
run: |
31+
mv language-server/build/libs/samt-ls-*.jar language-server/build/libs/samt-ls.jar
32+
33+
- name: Create GitHub Release
3034
uses: softprops/action-gh-release@v1
3135
with:
3236
files: |
@@ -36,3 +40,11 @@ jobs:
3640
fail_on_unmatched_files: true
3741
draft: true
3842
generate_release_notes: true
43+
44+
- name: Publish to Sonatype OSSRH
45+
run: ./gradlew --no-daemon publishMavenPublicationToOSSRHRepository
46+
env:
47+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
48+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
49+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SECRET }}
50+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PGP_PASSWORD }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish Snapshot
2+
on:
3+
push:
4+
branches: [main]
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-java@v3
12+
with:
13+
distribution: temurin
14+
java-version: 17
15+
- name: Setup Gradle
16+
uses: gradle/gradle-build-action@v2
17+
18+
- name: Publish Snapshot to Sonatype OSSRH
19+
run: ./gradlew --no-daemon publishMavenPublicationToOSSRHRepository
20+
env:
21+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
22+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

build.gradle.kts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
alias(libs.plugins.kover)
3+
alias(libs.plugins.versioning)
34
}
45

56
repositories {
@@ -8,9 +9,7 @@ repositories {
89

910
dependencies {
1011
kover(project(":common"))
11-
kover(project(":lexer"))
12-
kover(project(":parser"))
13-
kover(project(":semantic"))
12+
kover(project(":compiler"))
1413
kover(project(":cli"))
1514
kover(project(":language-server"))
1615
kover(project(":samt-config"))
@@ -28,3 +27,15 @@ koverReport {
2827
}
2928
}
3029
}
30+
31+
version = "0.0.0-SNAPSHOT"
32+
gitVersioning.apply {
33+
refs {
34+
branch(".+") {
35+
version = "\${ref}-SNAPSHOT"
36+
}
37+
tag("v(?<version>.*)") {
38+
version = "\${ref.version}"
39+
}
40+
}
41+
}

buildSrc/src/main/kotlin/samt-core.kotlin-conventions.gradle.kts renamed to buildSrc/src/main/kotlin/samt-core.kotlin-jvm.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ repositories {
2222
mavenCentral()
2323
}
2424

25-
group = "samt-core"
25+
group = "tools.samt"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
plugins {
2+
id("samt-core.kotlin-jvm")
3+
`java-library`
4+
`maven-publish`
5+
signing
6+
}
7+
8+
val mavenName: String by project.extra
9+
val mavenDescription: String by project.extra
10+
11+
publishing {
12+
publications {
13+
create<MavenPublication>("maven") {
14+
pom {
15+
name.set(provider { mavenName })
16+
description.set(provider { mavenDescription })
17+
url.set("https://github.com/samtkit/core")
18+
licenses {
19+
license {
20+
name.set("MIT License")
21+
url.set("https://github.com/samtkit/core/blob/main/LICENSE")
22+
}
23+
}
24+
developers {
25+
developer {
26+
name.set("Pascal Honegger")
27+
email.set("pascal.honegger@samt.tools")
28+
organization.set("Simple API Modeling Toolkit")
29+
organizationUrl.set("https://github.com/samtkit")
30+
}
31+
developer {
32+
name.set("Marcel Joss")
33+
email.set("marcel.joss@samt.tools")
34+
organization.set("Simple API Modeling Toolkit")
35+
organizationUrl.set("https://github.com/samtkit")
36+
}
37+
developer {
38+
name.set("Leonard Schütz")
39+
email.set("leonard.schuetz@samt.tools")
40+
organization.set("Simple API Modeling Toolkit")
41+
organizationUrl.set("https://github.com/samtkit")
42+
}
43+
}
44+
scm {
45+
connection.set("scm:git:git://github.com/samtkit/core.git")
46+
developerConnection.set("scm:git:ssh://github.com/samtkit/core.git")
47+
url.set("https://github.com/samtkit/core")
48+
}
49+
}
50+
from(components["java"])
51+
}
52+
}
53+
54+
repositories {
55+
maven {
56+
name = "OSSRH"
57+
url = if (version.toString().endsWith("-SNAPSHOT")) {
58+
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
59+
} else {
60+
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
61+
}
62+
credentials {
63+
username = System.getenv("SONATYPE_USERNAME")
64+
password = System.getenv("SONATYPE_PASSWORD")
65+
}
66+
}
67+
}
68+
}
69+
70+
signing {
71+
isRequired = !version.toString().endsWith("-SNAPSHOT")
72+
val signingKey: String? by project
73+
val signingPassword: String? by project
74+
useInMemoryPgpKeys(signingKey, signingPassword)
75+
sign(publishing.publications["maven"])
76+
}

cli/build.gradle.kts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
application
3-
id("samt-core.kotlin-conventions")
3+
id("samt-core.kotlin-jvm")
44
alias(libs.plugins.shadow)
55
kotlin("plugin.serialization")
66
alias(libs.plugins.kover)
@@ -11,12 +11,9 @@ dependencies {
1111
implementation(libs.mordant)
1212
implementation(libs.kotlinx.serialization.json)
1313
implementation(project(":common"))
14-
implementation(project(":lexer"))
15-
implementation(project(":parser"))
16-
implementation(project(":semantic"))
14+
implementation(project(":compiler"))
1715
implementation(project(":samt-config"))
1816
implementation(project(":codegen"))
19-
implementation(project(":public-api"))
2017
}
2118

2219
application {

codegen/build.gradle.kts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
plugins {
2-
id("samt-core.kotlin-conventions")
2+
id("samt-core.kotlin-jvm")
3+
id("samt-core.library")
34
alias(libs.plugins.kover)
45
}
56

7+
val mavenName: String by extra("SAMT CodeGen")
8+
val mavenDescription: String by extra("Call SAMT plugins to generate code from SAMT files.")
9+
610
dependencies {
711
implementation(project(":common"))
8-
implementation(project(":parser"))
9-
implementation(project(":semantic"))
10-
implementation(project(":public-api"))
11-
testImplementation(project(":lexer"))
12+
implementation(project(":compiler"))
13+
api(project(":public-api"))
1214
testImplementation(project(":samt-config"))
1315
}

codegen/src/main/kotlin/tools/samt/codegen/http/HttpTransport.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,27 @@ object HttpTransportConfigurationParser : TransportConfigurationParser {
8181
// and can generate default configurations for operations that have no explicit configuration.
8282

8383
// check for duplicate method/path combinations within current service
84-
for (operation in parsedOperations) {
85-
if (operation.path == path && operation.method == methodEnum) {
86-
val duplicate = operation
87-
params.reportError("Operation '${serviceName}.${operationName}' cannot be mapped to the same method and path combination ($method $servicePath$path) as operation '${serviceName}.${duplicate.name}'", operationConfig)
84+
for (parsedOperation in parsedOperations) {
85+
if (parsedOperation.path == path && parsedOperation.method == methodEnum) {
86+
params.reportError(
87+
"Operation '${serviceName}.${operationName}' cannot be mapped to the same method and path combination ($method $servicePath$path) as operation '${serviceName}.${parsedOperation.name}'",
88+
operationConfig
89+
)
8890
continue@operationConfigLoop
8991
}
9092
}
9193

9294
// check for duplicate method/path combinations within previously declared services
93-
for (service in parsedServices.filter { it.path == servicePath }) {
94-
val duplicate = service.operations.find { op ->
95+
for (parsedService in parsedServices.filter { it.path == servicePath }) {
96+
val duplicate = parsedService.operations.find { op ->
9597
op.path == path && op.method == methodEnum
9698
}
9799

98100
if (duplicate != null) {
99-
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)
101+
params.reportError(
102+
"Operation '${serviceName}.${operationName}' cannot be mapped to the same method and path combination ($method ${parsedService.path}$path) as operation '${parsedService.name}.${duplicate.name}'",
103+
operationConfig
104+
)
100105
continue@operationConfigLoop
101106
}
102107
}

common/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
plugins {
2-
id("samt-core.kotlin-conventions")
2+
id("samt-core.kotlin-jvm")
3+
id("samt-core.library")
34
alias(libs.plugins.kover)
45
}
6+
7+
val mavenName: String by extra("SAMT Common")
8+
val mavenDescription: String by extra("Common SAMT module")

compiler/build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
id("samt-core.kotlin-jvm")
3+
id("samt-core.library")
4+
alias(libs.plugins.kover)
5+
}
6+
7+
val mavenName: String by extra("SAMT Compiler")
8+
val mavenDescription: String by extra("Parse, analyze, and do whatever you desire with SAMT files.")
9+
10+
dependencies {
11+
implementation(kotlin("reflect"))
12+
implementation(project(":common"))
13+
}

0 commit comments

Comments
 (0)