From bdf8e9cc91739d9a619e7632dfb9a08d800639c7 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Thu, 14 Dec 2023 08:55:54 +0000 Subject: [PATCH] publish.gradle.kts: GitHubPackages task added --- publish.gradle.kts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/publish.gradle.kts b/publish.gradle.kts index 5e780a6..bd29b83 100644 --- a/publish.gradle.kts +++ b/publish.gradle.kts @@ -22,6 +22,28 @@ allprojects { // Default is Maven buildDirectory publish only url = uri(layout.buildDirectory.dir("repo")) } + + + + if(findProperty("doGitHubPackagesPublish") == "true") { + val GITHUB_ACTOR = System.getenv("GITHUB_USERNAME") ?: System.getenv("GITHUB_ACTOR") ?: throw IllegalArgumentException() + val GITHUB_TOKEN = System.getenv("GITHUB_TOKEN") ?: System.getenv("GH_TOKEN") ?: throw IllegalArgumentException() + val GITHUB_REPOSITORY = System.getenv("GITHUB_REPOSITORY") + + assert(GITHUB_ACTOR.isNotEmpty() == true) + assert(GITHUB_TOKEN.isNotEmpty() == true) + assert(GITHUB_REPOSITORY.isNotEmpty() == true) + + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/${GITHUB_REPOSITORY}") + credentials { + username = GITHUB_ACTOR + password = GITHUB_TOKEN + } + } + } } } } +