Skip to content

Commit

Permalink
SNAPSHOT publishing #2
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Feb 18, 2024
1 parent c50f3f2 commit 0b8edf2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
5 changes: 2 additions & 3 deletions build-logic/src/main/kotlin/internal/publishing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ internal 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
*/
internal fun Project.configureGitHub(sonatypeOptions: SonatypeOptions?, githubOptions: GithubOptions?) {
internal fun Project.configureGitHub(projectOptions: ProjectOptions, sonatypeOptions: SonatypeOptions?, githubOptions: GithubOptions?) {
if (githubOptions != null && this == rootProject && sonatypeOptions != null) {
val publishIfNeeded = project.publishIfNeededTaskProvider()
val ossStagingReleaseTask =
Expand All @@ -159,8 +159,7 @@ internal fun Project.configureGitHub(sonatypeOptions: SonatypeOptions?, githubOp
val eventName = System.getenv("GITHUB_EVENT_NAME")
val ref = System.getenv("GITHUB_REF")

if (eventName == "push" && ref == "refs/heads/${githubOptions.mainBranch}" && project.version.toString()
.endsWith("-SNAPSHOT")
if (eventName == "push" && ref == "refs/heads/${githubOptions.mainBranch}" && projectOptions.version.endsWith("-SNAPSHOT")
) {
project.logger.log(LogLevel.LIFECYCLE, "Deploying snapshot to OssSnapshot...")
publishIfNeeded.dependsOn(project.tasks.named("publishAllPublicationsToOssSnapshotsRepository"))
Expand Down
21 changes: 12 additions & 9 deletions build-logic/src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ private val sonatypeOptions = System.getenv("OSSRH_USER")?.let {
)
}

private val projectOptions = ProjectOptions(
groupId = "com.gradleup.gratatouille",
version = "0.0.1-SNAPSHOT",
descriptions = "Cook yourself delicious Gradle plugins",
vcsUrl = "https://github.com/GradleUp/gratatouille",
developers = "GradleUp authors",
license = "MIT License",
licenseUrl = "https://github.com/GradleUp/gratatouille/blob/main/LICENSE"
)

fun Project.configureLib() {
targetJdk(11)

configurePublishing(
projectOptions = ProjectOptions(
groupId = "com.gradleup.gratatouille",
version = "0.0.1-SNAPSHOT",
descriptions = "Cook yourself delicious Gradle plugins",
vcsUrl = "https://github.com/GradleUp/gratatouille",
developers = "GradleUp authors",
license = "MIT License",
licenseUrl = "https://github.com/GradleUp/gratatouille/blob/main/LICENSE"
),
projectOptions = projectOptions,
sonatypeOptions = sonatypeOptions,
signingOptions = System.getenv("GPG_KEY")?.let {
SigningOptions(
Expand All @@ -40,6 +42,7 @@ fun Project.configureLib() {

fun Project.configureRoot() {
configureGitHub(
projectOptions = projectOptions,
sonatypeOptions = sonatypeOptions,
githubOptions = GithubOptions(
mainBranch = "main",
Expand Down

0 comments on commit 0b8edf2

Please sign in to comment.