Skip to content

Commit

Permalink
Merge ed978cf into master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 21, 2022
2 parents fe72e9f + ed978cf commit 811d79d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "io.github.rtmigo"
version = "0.3.1-SNAPSHOT" //
version = "0.4.0" // -SNAPSHOT

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/Build.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT EDIT. Generated by Gradle task "generateBuildKt"
object Build {
const val version = "0.3.0"
const val version = "0.4.0"
const val date = "2022-10-21"
}
39 changes: 31 additions & 8 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
**/

import com.github.ajalt.clikt.core.*
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.*
import kotlinx.coroutines.runBlocking
import maven.*
import stages.build.*
import stages.sign.*
import stages.upload.*
import tools.rethrowingState
import java.nio.file.*
import kotlin.io.path.absolute

Expand All @@ -24,7 +24,7 @@ class Cli : NoOpCliktCommand(
init {
versionOption(Build.version) {
"$commandName $it (${Build.date})\n" +
"MIT (c) Artsiom iG <[email protected]>\n" +
"ISC (c) Artsiom iG <[email protected]>\n" +
"http://github.com/rtmigo/mavence"
}
}
Expand All @@ -41,24 +41,47 @@ private suspend fun gaa(): GroupArtifact {

data class CliConfig(val trace: Boolean)

open class CheckCentral : CliktCommand(
help = "Check that environment is set for publishing to Maven Central") {
override fun run() = catchingCommand(this) {
fun checkVar(k: String) = rethrowingState(
{ "Environment variable $k is not set." },
{ check(System.getenv(k).isNotBlank()) })
checkVar(EnvVarNames.MAVEN_GPG_KEY)
checkVar(EnvVarNames.MAVEN_GPG_PASSWORD)
checkVar(EnvVarNames.SONATYPE_USERNAME)
checkVar(EnvVarNames.SONATYPE_PASSWORD)
System.err.println("At first glance, everything is OK.")
}
}

open class Local(help: String = "Build, publish to $m2str") : CliktCommand(help = help) {
override fun run() = catchingCommand(this) {
cmdLocal(gaa(), isFinal = true)
Unit
}
}

object EnvVarNames {
const val MAVEN_GPG_KEY = "MAVEN_GPG_KEY"
const val MAVEN_GPG_PASSWORD = "MAVEN_GPG_PASSWORD"
const val SONATYPE_USERNAME = "SONATYPE_USERNAME"
const val SONATYPE_PASSWORD = "SONATYPE_PASSWORD"
}



open class Stage(help: String = "Build, sign, publish to OSSRH Staging") :
Local(help = help) {
val gpgKey by option("--gpg-key", envvar = "MAVEN_GPG_KEY").required()
val gpgPwd by option("--gpg-password", envvar = "MAVEN_GPG_PASSWORD").required()
val gpgKey by option("--gpg-key", envvar = EnvVarNames.MAVEN_GPG_KEY).required()
val gpgPwd by option("--gpg-password", envvar = EnvVarNames.MAVEN_GPG_PASSWORD).required()

protected val sonatypeUser by option(
"--sonatype-username",
envvar = "SONATYPE_USERNAME").required()
envvar = EnvVarNames.SONATYPE_USERNAME).required()
protected val sonatypePassword by option(
"--sonatype-password",
envvar = "SONATYPE_PASSWORD").required()
envvar = EnvVarNames.SONATYPE_PASSWORD).required()

override fun run() = catchingCommand(this) {
cmdSign(
Expand Down Expand Up @@ -102,13 +125,13 @@ fun catchingCommand(cmd: CliktCommand, block: suspend () -> Unit) {
e.printStackTrace()
else
System.err.println("ERROR: $e")
System.err.println("Run with --trace to see full stack trace.")
System.err.println("Run with --trace to see full stack trace.")
}

}

fun main(args: Array<String>) {
Cli()
.subcommands(Local(), Stage(), Central())
.subcommands(Local(), Stage(), Central(), CheckCentral())
.main(args)
}

0 comments on commit 811d79d

Please sign in to comment.