Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from linked-planet/maintenance/dependency-update
Browse files Browse the repository at this point in the history
Updated Publishing method
  • Loading branch information
Patrick Louis authored Nov 24, 2022
2 parents 1c7d25d + b992a91 commit 39b2788
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 22 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ktor-onelogin-saml master
on:
push:
branches: [ master, maintenance/dependency-update ]
release:
types: [ published ]

jobs:
master:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-ktor-onelogin-saml-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-ktor-onelogin-saml-
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Build and test Library
run: ./gradlew build --info

- name: Publish Library to Maven Central
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
49 changes: 27 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import nu.studer.gradle.credentials.domain.CredentialsContainer
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

// print gradle version as we might run on different machines as well as in the cloud
println("Gradle Version: " + GradleVersion.current().toString())

group = "com.linked-planet.ktor"
version = "1.2.1-ktor-2.1.3"
val libraryVersion = scmVersion.version
group = "com.linked-planet"
version = libraryVersion

val kotlinVersion = "1.7.21"
val ktorVersion = "2.1.3"
Expand All @@ -17,6 +17,9 @@ plugins {
id("org.jetbrains.dokka") version "0.10.1"
id("com.github.ben-manes.versions") version "0.28.0"
id("nu.studer.credentials") version "2.1"
id("pl.allegro.tech.build.axion-release") version "1.13.6"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("signing")
`maven-publish`
}

Expand All @@ -37,6 +40,15 @@ tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
}

signing {
useInMemoryPgpKeys(
findProperty("signingKey").toString(),
findProperty("signingPassword").toString()
)

sign(publishing.publications)
}

publishing {
publications {
create<MavenPublication>("ktor-onelogin-saml") {
Expand All @@ -49,7 +61,7 @@ publishing {
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
Expand All @@ -68,32 +80,25 @@ publishing {
developerConnection.set("scm:git:git://github.com/linked-planet/ktor-onelogin-saml.git")
}
}
repositories {
mavenCentral()
mavenLocal()
}
}
}
}

// obtain passwords from gradle credentials plugin
gradle.taskGraph.whenReady {
if (allTasks.any { it is Sign }) {
val credentials: CredentialsContainer by ext
allprojects {
extra["signing.password"] = credentials.getProperty("signingPassword")
}
}
if (allTasks.any {
it.name in setOf("uploadArchives", "closeRepository", "releaseRepository", "closeAndReleaseRepository")
}) {
val credentials: CredentialsContainer by ext
allprojects {
extra["nexusPassword"] = credentials.getProperty("nexusToken")
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}

// do not generate extra load on Nexus with new staging repository if signing fails
val initializeSonatypeStagingRepository by tasks.existing
initializeSonatypeStagingRepository {
shouldRunAfter(tasks.withType<Sign>())
}

tasks {
register("dokkaJavadoc", DokkaTask::class) {
outputFormat = "javadoc"
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/linkedplanet/ktor/Saml.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ suspend fun PipelineContext<Unit, ApplicationCall>.redirectToIdentityProvider()

suspend fun PipelineContext<Unit, ApplicationCall>.withSAMLAuth(handler: suspend (Auth) -> Unit) {
val auth = Auth(SamlConfig.saml2Settings, call.getServletRequest(), call.getServletResponse())
call
handler(auth)
}

Expand Down

0 comments on commit 39b2788

Please sign in to comment.