-
Notifications
You must be signed in to change notification settings - Fork 2
fix: Add iosSimulatorArm64, allow overriding publication validation
#117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
e423548
79b5a61
e347e3a
8ed9479
8c8a550
8dcf82c
6acc807
9393e4f
ff88c9c
79d0f17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| */ | ||
| package aws.sdk.kotlin.gradle.dsl | ||
|
|
||
| import aws.sdk.kotlin.gradle.util.getOrNull | ||
| import aws.sdk.kotlin.gradle.util.verifyRootProject | ||
| import io.github.gradlenexus.publishplugin.NexusPublishExtension | ||
| import org.gradle.api.Project | ||
|
|
@@ -36,6 +37,7 @@ private object EnvironmentVariables { | |
| const val GPG_PASSPHRASE = "JRELEASER_GPG_PASSPHRASE" | ||
| const val GPG_PUBLIC_KEY = "JRELEASER_GPG_PUBLIC_KEY" | ||
| const val GPG_SECRET_KEY = "JRELEASER_GPG_SECRET_KEY" | ||
| const val GENERIC_TOKEN = "JRELEASER_GENERIC_TOKEN" | ||
| } | ||
|
|
||
| internal val ALLOWED_PUBLICATION_NAMES = setOf( | ||
|
|
@@ -56,22 +58,27 @@ internal val ALLOWED_PUBLICATION_NAMES = setOf( | |
| "dynamodb-mapper-schema-generatorPluginMarkerMaven", | ||
| ) | ||
|
|
||
| internal val KOTLIN_NATIVE_PUBLICATION_NAMES = setOf( | ||
| internal val ALLOWED_KOTLIN_NATIVE_PUBLICATION_NAMES = setOf( | ||
| "iosArm64", | ||
| "iosSimulatorArm64", | ||
| "iosX64", | ||
|
|
||
| "linuxArm64", | ||
| "linuxX64", | ||
| "macosArm64", | ||
| "macosX64", | ||
| "mingwX64", | ||
| ) | ||
|
|
||
| // TODO Refactor to support project names _or_ publication group names. | ||
| // aws-crt-kotlin is not published with a group name, so we need to check project names instead. | ||
| private val KOTLIN_NATIVE_PROJECT_NAMES = setOf( | ||
| "aws-crt-kotlin", | ||
| // Group names which are allowed to publish K/N artifacts | ||
| private val ALLOWED_KOTLIN_NATIVE_GROUP_NAMES = setOf( | ||
| "aws.sdk.kotlin.crt", | ||
| ) | ||
|
|
||
| // Optional override to the above set. | ||
| // Used to support local development where you want to run publishToMavenLocal in smithy-kotlin, aws-sdk-kotlin. | ||
| internal const val OVERRIDE_KOTLIN_NATIVE_GROUP_NAME_VALIDATION = "aws.kotlin.native.allowPublication" | ||
|
|
||
| /** | ||
| * Mark this project as excluded from publishing | ||
| */ | ||
|
|
@@ -237,10 +244,7 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = " | |
| if (!secretKey.isNullOrBlank() && !passphrase.isNullOrBlank()) { | ||
| apply(plugin = "signing") | ||
| extensions.configure<SigningExtension> { | ||
| useInMemoryPgpKeys( | ||
| secretKey, | ||
| passphrase, | ||
| ) | ||
| useInMemoryPgpKeys(secretKey, passphrase) | ||
| sign(publications) | ||
| } | ||
|
|
||
|
|
@@ -306,20 +310,19 @@ fun Project.configureNexus( | |
| fun Project.configureJReleaser() { | ||
| verifyRootProject { "JReleaser configuration must be applied to the root project only" } | ||
|
|
||
| var missingVariables = false | ||
| listOf( | ||
| val requiredVariables = listOf( | ||
| EnvironmentVariables.MAVEN_CENTRAL_USERNAME, | ||
| EnvironmentVariables.MAVEN_CENTRAL_TOKEN, | ||
| EnvironmentVariables.GPG_PASSPHRASE, | ||
| EnvironmentVariables.GPG_PUBLIC_KEY, | ||
| EnvironmentVariables.GPG_SECRET_KEY, | ||
| ).forEach { | ||
| if (System.getenv(it).isNullOrBlank()) { | ||
| missingVariables = true | ||
| logger.info("Skipping JReleaser configuration, missing required environment variable: $it") | ||
| } | ||
| EnvironmentVariables.GENERIC_TOKEN, | ||
| ) | ||
|
|
||
| if (!requiredVariables.all { System.getenv(it).isNotBlank() }) { | ||
| println("Skipping JReleaser configuration, missing one or more required environment variables: ${requiredVariables.joinToString()}") | ||
| return | ||
| } | ||
| if (missingVariables) return | ||
|
|
||
| // Get SDK version from gradle.properties | ||
| val sdkVersion: String by project | ||
|
|
@@ -330,23 +333,22 @@ fun Project.configureJReleaser() { | |
| version = sdkVersion | ||
| } | ||
|
|
||
| // FIXME We're currently signing the artifacts twice. Once using the logic in configurePublishing above, | ||
| // and the second time during JReleaser's signing stage. | ||
| signing { | ||
| active = Active.ALWAYS | ||
| armored = true | ||
| } | ||
|
|
||
| // Used for creating a tagged release, uploading files and generating changelogs. | ||
| // In the future we can set this up to push release tags to GitHub, but for now it's | ||
| // set up to do nothing. | ||
| // https://jreleaser.org/guide/latest/reference/release/index.html | ||
| // JReleaser requires a releaser to be configured even though we don't use it. | ||
| // https://github.com/jreleaser/jreleaser/discussions/1725#discussioncomment-10674529 | ||
| release { | ||
| generic { | ||
| enabled = true | ||
| skipRelease = true | ||
| } | ||
| } | ||
|
|
||
| // Used to announce a release to configured announcers. | ||
| // We don't announce our releases anywhere | ||
| // https://jreleaser.org/guide/latest/reference/announce/index.html | ||
| announce { | ||
| active = Active.NEVER | ||
|
|
@@ -356,14 +358,13 @@ fun Project.configureJReleaser() { | |
| maven { | ||
| mavenCentral { | ||
| create("maven-central") { | ||
| active = Active.ALWAYS | ||
| url = "https://central.sonatype.com/api/v1/publisher" | ||
| stagingRepository(rootProject.layout.buildDirectory.dir("m2").get().toString()) | ||
| artifacts { | ||
| artifactOverride { | ||
| artifactId = "version-catalog" | ||
| jar = false | ||
| verifyPom = false // jreleaser doesn't understand toml packaging | ||
| jar = false // Version catalogs don't produce a JAR | ||
| verifyPom = false // JReleaser fails when processing <packaging>toml</packaging> tags: `Unknown packaging: toml` | ||
|
||
| } | ||
| } | ||
| maxRetries = 100 | ||
|
|
@@ -381,17 +382,22 @@ internal fun isAvailableForPublication(project: Project, publication: MavenPubli | |
| // Check SKIP_PUBLISH_PROP | ||
| if (project.extra.has(Properties.SKIP_PUBLISHING)) shouldPublish = false | ||
|
|
||
| // Only publish publications with the configured group from JReleaser or everything if JReleaser group is not configured | ||
| val publishGroupName = System.getenv(EnvironmentVariables.GROUP_ID) | ||
| shouldPublish = shouldPublish && (publishGroupName == null || publication.groupId.startsWith(publishGroupName)) | ||
|
|
||
| // Validate publication name is allowed to be published | ||
| shouldPublish = shouldPublish && | ||
| ( | ||
| ALLOWED_PUBLICATION_NAMES.any { publication.name.equals(it, ignoreCase = true) } || | ||
| // standard publication | ||
| (KOTLIN_NATIVE_PUBLICATION_NAMES.any { publication.name.equals(it, ignoreCase = true) } && KOTLIN_NATIVE_PROJECT_NAMES.any { project.name.equals(it, ignoreCase = true) }) // Kotlin/Native publication | ||
| ) | ||
| // Allow overriding K/N publications for local development | ||
| val overrideGroupNameValidation = project.extra.getOrNull<String>(OVERRIDE_KOTLIN_NATIVE_GROUP_NAME_VALIDATION) == "true" | ||
|
|
||
| // Validate publication name | ||
| if (publication.name in ALLOWED_PUBLICATION_NAMES) { | ||
| // Standard publication | ||
| } else if (publication.name in ALLOWED_KOTLIN_NATIVE_PUBLICATION_NAMES) { | ||
| // Kotlin/Native publication | ||
| if (overrideGroupNameValidation && publication.groupId !in ALLOWED_KOTLIN_NATIVE_PUBLICATION_NAMES) { | ||
| println("Overriding K/N publication, project=${project.name}; publication=${publication.name}; group=${publication.groupId}") | ||
| } else { | ||
| shouldPublish = shouldPublish && publication.groupId in ALLOWED_KOTLIN_NATIVE_GROUP_NAMES | ||
| } | ||
| } else { | ||
| shouldPublish = false | ||
| } | ||
|
|
||
| return shouldPublish | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why did this switch from
logger.infotoprintln?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I noticed this too.
loggeris only available within the context of a Gradle taskThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry logger was available there, but not in
isAvailableForPublication