Skip to content

Commit

Permalink
Merge pull request #26 from outfoxx/task/rel-workflow-cleanup
Browse files Browse the repository at this point in the history
Cleanup workflows and automate maven releasing
  • Loading branch information
kdubb authored Dec 6, 2022
2 parents a8681ef + 3a11d5e commit 65686b2
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 60 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: oracle
java-version: '11'
distribution: adopt

- name: Build & Test
uses: burrunan/gradle-cache-action@v1
Expand All @@ -31,12 +31,10 @@ jobs:
job-id: jdk11-build-test
arguments: check sonar

- name: Upload Reports
uses: actions/upload-artifact@v3
if: always()
- name: Report Tests
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: reports
path: |
core/build/reports/
okhttp/build/reports/
jdk/build/reports/
name: Tests Results
path: "**/build/test-results/*/*.xml"
reporter: java-junit
10 changes: 5 additions & 5 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: oracle
java-version: '11'
distribution: adopt

- name: Build Artifacts & Documentation
uses: burrunan/gradle-cache-action@v1
Expand All @@ -40,11 +40,11 @@ jobs:
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
with:
job-id: jdk11-build-test
arguments: publishRelease -x test
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository githubRelease -x test
properties: |
releaseVersion=${{ github.ref_name }}
ossrhUsername=${{ secrets.OSSRH_USER }}
ossrhPassword=${{ secrets.OSSRH_PASS }}
sonatypeUsername=${{ secrets.OSSRH_USER }}
sonatypePassword=${{ secrets.OSSRH_PASS }}
github.token=${{ secrets.GITHUB_TOKEN }}
- name: Publish Documentation
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: oracle
java-version: '11'
distribution: adopt

- name: Build Artifacts & Documentation
uses: burrunan/gradle-cache-action@v1
Expand All @@ -34,10 +34,10 @@ jobs:
uses: burrunan/gradle-cache-action@v1
with:
job-id: jdk11-build-test
arguments: publishAllPublicationsToMavenCentralRepository
arguments: publishToSonatype
properties: |
ossrhUsername=${{ secrets.OSSRH_USER }}
ossrhPassword=${{ secrets.OSSRH_PASS }}
sonatypeUsername=${{ secrets.OSSRH_USER }}
sonatypePassword=${{ secrets.OSSRH_PASS }}
- name: Publish Documentation
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
62 changes: 25 additions & 37 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id("org.jetbrains.dokka")
id("com.github.breadmoirai.github-release")
id("org.sonarqube")
id("io.github.gradle-nexus.publish-plugin")


kotlin("jvm") apply (false)
Expand Down Expand Up @@ -132,7 +133,7 @@ configure(moduleNames.map { project(":sunday-$it") }) {
}

configure<DetektExtension> {
input = files("src/main/kotlin")
source = files("src/main/kotlin")

config = files("${rootProject.layout.projectDirectory}/src/main/detekt/detekt.yml")
buildUponDefaultConfig = true
Expand Down Expand Up @@ -176,6 +177,9 @@ configure(moduleNames.map { project(":sunday-$it") }) {
create<MavenPublication>("library") {
from(components["java"])

suppressPomMetadataWarningsFor("testFixturesApiElements")
suppressPomMetadataWarningsFor("testFixturesRuntimeElements")

pom {

when (project.name) {
Expand Down Expand Up @@ -246,20 +250,6 @@ configure(moduleNames.map { project(":sunday-$it") }) {
}

}

repositories {
maven {
name = "MavenCentral"
val snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
val releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
url = uri(if (isSnapshot) snapshotUrl else releaseUrl)
credentials {
username = project.findProperty("ossrhUsername")?.toString()
password = project.findProperty("ossrhPassword")?.toString()
}
}
}

}

configure<SigningExtension> {
Expand All @@ -276,6 +266,11 @@ configure(moduleNames.map { project(":sunday-$it") }) {
onlyIf { !isSnapshot }
}


//
// ANALYSIS
//

sonarqube {
properties {
property("sonar.sources", "src/main")
Expand Down Expand Up @@ -308,6 +303,16 @@ sonarqube {
}
}


//
// DOCS
//

tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(buildDir.resolve("dokka/${releaseVersion}"))
}


//
// RELEASING
//
Expand All @@ -317,9 +322,9 @@ githubRelease {
repo("sunday-kt")
tagName(releaseVersion)
targetCommitish("main")
releaseName("v${releaseVersion}")
releaseName("🚀 v${releaseVersion}")
generateReleaseNotes(true)
draft(true)
draft(false)
prerelease(!releaseVersion.matches("""^\d+\.\d+\.\d+$""".toRegex()))
releaseAssets(
moduleNames.flatMap { moduleName ->
Expand All @@ -334,25 +339,8 @@ githubRelease {
)
}

tasks {

dokkaHtmlMultiModule.configure {
outputDirectory.set(buildDir.resolve("dokka/${releaseVersion}"))
}

register("publishMavenRelease") {
dependsOn(
moduleNames.map { moduleName ->
":sunday-$moduleName:publishAllPublicationsToMavenCentralRepository"
}
)
}

register("publishRelease") {
dependsOn(
"publishMavenRelease",
"githubRelease"
)
nexusPublishing {
repositories {
sonatype()
}

}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ licenserPluginVersion=0.6.1
kotlinterPluginVersion=3.4.4
detektPluginVersion=1.22.0
githubReleasePluginVersion=2.4.1
sonarqubeVersion=3.5.0.2730
sonarqubePluginVersion=3.5.0.2730
nexusPublishPluginVersion=1.1.0

slf4jVersion=2.0.4
kotlinCoroutinesVersion=1.6.4
Expand Down
6 changes: 4 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pluginManagement {
val kotlinterPluginVersion: String by settings
val detektPluginVersion: String by settings
val githubReleasePluginVersion: String by settings
val sonarqubeVersion: String by settings
val sonarqubePluginVersion: String by settings
val nexusPublishPluginVersion: String by settings

plugins {
kotlin("jvm") version kotlinPluginVersion
Expand All @@ -21,7 +22,8 @@ pluginManagement {
id("org.jmailen.kotlinter") version kotlinterPluginVersion
id("io.gitlab.arturbosch.detekt") version detektPluginVersion
id("com.github.breadmoirai.github-release") version githubReleasePluginVersion
id("org.sonarqube") version sonarqubeVersion
id("org.sonarqube") version sonarqubePluginVersion
id("io.github.gradle-nexus.publish-plugin") version nexusPublishPluginVersion
}

}
Expand Down

0 comments on commit 65686b2

Please sign in to comment.