Skip to content

Commit

Permalink
test SNAPSHOTs
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Feb 18, 2024
1 parent d670e6d commit c50f3f2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: gradle/gradle-build-action@v2
- run: ./gradlew publishIfNeeded
env:
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

package internal
import org.gradle.api.Project
import org.gradle.api.tasks.compile.JavaCompile
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun Project.targetJdk(jdk: Int) {
internal fun Project.targetJdk(jdk: Int) {
tasks.withType(JavaCompile::class.java) {
it.options.release.set(jdk)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package internal

import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import net.mbonnin.vespene.lib.NexusStagingClient
Expand All @@ -20,20 +22,20 @@ import java.net.URI
import kotlin.time.Duration.Companion.minutes


enum class SonatypeHost {
internal enum class SonatypeHost {
Ossrh,
OssrhS01,
}


class SonatypeOptions(
internal class SonatypeOptions(
val username: String,
val password: String,
val host: SonatypeHost,
val stagingProfile: String
)

class ProjectOptions(
internal class ProjectOptions(
val groupId: String,
val version: String,
val descriptions: String,
Expand All @@ -43,7 +45,7 @@ class ProjectOptions(
val licenseUrl: String,
)

class SigningOptions(
internal class SigningOptions(
/**
* GPG_PRIVATE_KEY must contain the armoured private key that starts with -----BEGIN PGP PRIVATE KEY BLOCK-----
* It can be obtained with gpg --armour --export-secret-keys KEY_ID
Expand All @@ -52,7 +54,7 @@ class SigningOptions(
val privateKeyPassword: String
)

class GithubOptions(
internal class GithubOptions(
val mainBranch: String,
val autoRelease: Boolean
)
Expand All @@ -64,7 +66,7 @@ class GithubOptions(
* @param sonatypeOptions sonatype options
* @param signingOptions signing options. May be null to skip signing
*/
fun Project.configurePublishing(
internal fun Project.configurePublishing(
projectOptions: ProjectOptions,
sonatypeOptions: SonatypeOptions?,
signingOptions: SigningOptions?,
Expand Down Expand Up @@ -148,7 +150,7 @@ fun Project.configurePublishing(
* @param githubOptions CI options. May be null to skip publishing on CI. If non-null, creates `publishIfNeeded` task
* that publishes to SNAPSHOTS if the version ends with `-SNAPSHOT` or Maven Central else
*/
fun Project.configureGitHub(sonatypeOptions: SonatypeOptions?, githubOptions: GithubOptions?) {
internal fun Project.configureGitHub(sonatypeOptions: SonatypeOptions?, githubOptions: GithubOptions?) {
if (githubOptions != null && this == rootProject && sonatypeOptions != null) {
val publishIfNeeded = project.publishIfNeededTaskProvider()
val ossStagingReleaseTask =
Expand Down Expand Up @@ -210,7 +212,7 @@ private fun nexusStatingClient(sonatypeOptions: SonatypeOptions): NexusStagingCl
)
}

fun Project.getOrCreateRepoId(sonatypeOptions: SonatypeOptions): Provider<String> {
internal fun Project.getOrCreateRepoId(sonatypeOptions: SonatypeOptions): Provider<String> {
return getOrCreateRepoIdTask(
sonatypeOptions,
).map {
Expand Down Expand Up @@ -333,7 +335,7 @@ private fun RepositoryHandler.mavenSonatypeSnapshot(
}
}

fun RepositoryHandler.mavenSonatypeStaging(
internal fun RepositoryHandler.mavenSonatypeStaging(
project: Project,
sonatypeOptions: SonatypeOptions,
) = maven {
Expand Down
10 changes: 8 additions & 2 deletions build-logic/src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import internal.*
import internal.ProjectOptions
import internal.SonatypeHost
import internal.SonatypeOptions
import internal.configurePublishing
import internal.targetJdk
import org.gradle.api.Project

val sonatypeOptions = System.getenv("OSSRH_USER")?.let {
private val sonatypeOptions = System.getenv("OSSRH_USER")?.let {
SonatypeOptions(
username = it,
password = System.getenv("OSSRH_PASSWORD") ?: error("OSSRH_PASSWORD not found"),
Expand All @@ -15,7 +21,7 @@ fun Project.configureLib() {
configurePublishing(
projectOptions = ProjectOptions(
groupId = "com.gradleup.gratatouille",
version = "0.0.1",
version = "0.0.1-SNAPSHOT",
descriptions = "Cook yourself delicious Gradle plugins",
vcsUrl = "https://github.com/GradleUp/gratatouille",
developers = "GradleUp authors",
Expand Down

0 comments on commit c50f3f2

Please sign in to comment.