Skip to content

Commit b13b1db

Browse files
Merge pull request #4 from cybercoder-naj/feat/publish-maven
feat: publishing to maven central and docs to github pages
2 parents 75e832c + 6ef3e8c commit b13b1db

File tree

4 files changed

+134
-62
lines changed

4 files changed

+134
-62
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Publish Package to Maven Registry
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
create-release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Create a release
16+
uses: ncipollo/release-action@v1
17+
with:
18+
generateReleaseNotes: true
19+
20+
generate-docs:
21+
needs: create-release
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@v3
30+
31+
- name: Generate docs
32+
run: ./gradlew :dokkaHtml
33+
34+
- name: Bundle Docs
35+
uses: actions/upload-pages-artifact@v3
36+
with:
37+
path: "./docs"
38+
39+
publish-package:
40+
needs: create-release
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Gradle
48+
uses: gradle/actions/setup-gradle@v3
49+
50+
- name: Publish package
51+
run: ./gradlew :publish
52+
env:
53+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }}
54+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }}
55+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
56+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
57+
58+
deploy-docs:
59+
needs: [generate-docs, publish-package]
60+
61+
permissions:
62+
pages: write
63+
id-token: write
64+
65+
environment:
66+
name: github-pages
67+
url: ${{ steps.deployment.outputs.page_url }}
68+
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Deploy docs
72+
id: deployment
73+
uses: actions/deploy-pages@v3

build.gradle.kts

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import com.vanniktech.maven.publish.JavadocJar
2+
import com.vanniktech.maven.publish.KotlinJvm
3+
import com.vanniktech.maven.publish.SonatypeHost
14
import org.jetbrains.dokka.gradle.DokkaTask
25
import java.net.URI
36

47
plugins {
5-
kotlin("jvm") version "2.0.0"
6-
alias(libs.plugins.dokka)
7-
`java-library`
8+
kotlin("jvm") version "2.0.0"
9+
alias(libs.plugins.dokka)
10+
alias(libs.plugins.maven.publishing)
11+
`java-library`
812
}
913

1014
group = "io.github.cybercodernaj"
@@ -13,33 +17,70 @@ version = libs.versions.lib.get()
1317
val docsDir = layout.projectDirectory.dir("docs/")
1418

1519
repositories {
16-
mavenCentral()
20+
mavenCentral()
1721
}
1822

1923
dependencies {
20-
testImplementation(kotlin("test"))
24+
testImplementation(kotlin("test"))
2125
}
2226

2327
tasks.test {
24-
useJUnitPlatform()
28+
useJUnitPlatform()
2529
}
2630
kotlin {
27-
jvmToolchain(18)
31+
jvmToolchain(18)
2832
}
2933

3034
tasks.withType<DokkaTask>().configureEach {
31-
moduleName.set(project.name)
32-
moduleVersion.set(project.version.toString())
33-
outputDirectory.set(docsDir)
34-
dokkaSourceSets.configureEach {
35-
sourceLink {
36-
localDirectory.set(projectDir.resolve("src"))
37-
remoteUrl.set(URI.create("https://github.com/cybercoder-naj/Parkour/blob/main/src").toURL())
38-
remoteLineSuffix.set("#L")
39-
}
35+
moduleName.set(project.name)
36+
moduleVersion.set(project.version.toString())
37+
outputDirectory.set(docsDir)
38+
dokkaSourceSets.configureEach {
39+
sourceLink {
40+
localDirectory.set(projectDir.resolve("src"))
41+
remoteUrl.set(URI.create("https://github.com/cybercoder-naj/Parkour/blob/main/src").toURL())
42+
remoteLineSuffix.set("#L")
4043
}
44+
}
4145
}
4246

4347
tasks.clean {
44-
delete = setOf(docsDir, layout.buildDirectory)
48+
delete = setOf(docsDir, layout.buildDirectory)
49+
}
50+
51+
mavenPublishing {
52+
configure(KotlinJvm(
53+
javadocJar = JavadocJar.Dokka("dokkaHtml"),
54+
sourcesJar = true
55+
))
56+
57+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
58+
59+
coordinates(project.group.toString(), project.name, project.version.toString())
60+
61+
pom {
62+
name.set("Parkour")
63+
description.set("Parser Combinator library for Kotlin")
64+
inceptionYear.set("2024")
65+
url.set("https://github.com/cybercoder-naj/Parkour/")
66+
licenses {
67+
license {
68+
name.set("MIT License")
69+
url.set("https://github.com/cybercoder-naj/Parkour/blob/main/LICENSE")
70+
distribution.set("repo")
71+
}
72+
}
73+
developers {
74+
developer {
75+
id.set("cybercoder-naj")
76+
name.set("Nishant Aanjaney Jalan")
77+
url.set("https://github.com/cybercoder-naj/")
78+
}
79+
}
80+
scm {
81+
url.set("https://github.com/cybercoder-naj/Parkour/")
82+
connection.set("scm:git:git://github.com/cybercoder-naj/Parkour.git")
83+
developerConnection.set("scm:git:ssh://[email protected]/cybercoder-naj/Parkour.git")
84+
}
85+
}
4586
}

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
[versions]
44
lib = "0.0.1"
55
dokkaVer = "1.9.20"
6+
mavenPublishingVer = "0.28.0"
67

78
[plugins]
8-
dokka = { id = "org.jetbrains.dokka", version.ref = "dokkaVer" }
9+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokkaVer" }
10+
maven-publishing = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublishingVer" }

0 commit comments

Comments
 (0)