Skip to content

Commit

Permalink
Add properties for switching which JReleaser configuration to use dur…
Browse files Browse the repository at this point in the history
…ing releases (#2330)
  • Loading branch information
haydenbaker committed Jun 19, 2024
1 parent 4d8b5a9 commit 9106d59
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 123 deletions.
50 changes: 9 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
id "io.codearte.nexus-staging" version "0.30.0"
id "me.champeau.jmh" version "0.7.2"
id "com.github.johnrengelman.shadow" version "7.1.2"
id "org.jreleaser" version "1.11.0"
id "org.jreleaser" version "1.12.0" apply false
}

ext {
Expand All @@ -41,10 +41,6 @@ allprojects {
version = libraryVersion
}

// Only using JReleaser based on a flag allows going back to the old
// release process if necessary. We can remove this later.
def useJreleaser = project.hasProperty("useJreleaser")

// JReleaser publishes artifacts from a local staging repository, rather than maven local.
// https://jreleaser.org/guide/latest/examples/maven/staging-artifacts.html#_gradle
def stagingDirectory = rootProject.layout.buildDirectory.dir("staging")
Expand Down Expand Up @@ -138,22 +134,9 @@ subprojects {
publishing {
repositories {
// JReleaser's `publish` task publishes to all repositories, so only configure one.
if (useJreleaser) {
maven {
name = "localStaging"
url = stagingDirectory
}
} else {
mavenCentral {
name = "sonatypeNexus"
url = uri("https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/")
if (project.hasProperty("sonatypeUser")) {
credentials {
username = project.property("sonatypeUser")
password = project.property("sonatypePassword")
}
}
}
maven {
name = "localStaging"
url = stagingDirectory
}
}

Expand Down Expand Up @@ -290,7 +273,11 @@ allprojects {
}
}

if (useJreleaser) {
// We're using JReleaser in the smithy-cli subproject, so we want to have a flag to control
// which JReleaser configuration to use to prevent conflicts
if (project.hasProperty("release.main")) {
apply plugin: 'org.jreleaser'

jreleaser {
dryrun = false

Expand Down Expand Up @@ -336,22 +323,3 @@ if (useJreleaser) {
}
}
}

/*
* Sonatype Staging Finalization
* ====================================================
*
* When publishing to Maven Central, we need to close the staging
* repository and release the artifacts after they have been
* validated. This configuration is for the root project because
* it operates at the "group" level.
*/
if (!useJreleaser && project.hasProperty("sonatypeUser") && project.hasProperty("sonatypePassword")) {
apply plugin: "io.codearte.nexus-staging"
nexusStaging {
packageGroup = "software.amazon"
stagingProfileId = "e789115b6c941"
username = project.property("sonatypeUser")
password = project.property("sonatypePassword")
}
}
168 changes: 86 additions & 82 deletions smithy-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import java.nio.file.Paths
plugins {
id "application"
id "org.beryx.runtime" version "1.12.7"
id "org.jreleaser" version "1.11.0"
id "org.jreleaser" version "1.12.0" apply false
}

description = "This module implements the Smithy command line interface."
Expand Down Expand Up @@ -254,100 +254,104 @@ task integ(type: Test) {
tasks["integ"].dependsOn("runtime")

// ------ Setup Jreleaser -------
tasks["assembleDist"].dependsOn("runtimeZip")
tasks.assembleDist.doFirst {
// This is a workaround for a weird behavior.
// https://github.com/jreleaser/jreleaser/issues/1292
mkdir "$buildDir/jreleaser"
}

jreleaser {
gitRootSearch = true

project {
website = 'https://smithy.io'
authors = ['Smithy']
vendor = "Smithy"
license = 'Apache-2.0'
description = "Smithy CLI - A CLI for building, validating, querying, and iterating on Smithy models"
copyright = "2019"
if (project.hasProperty("release.cli")) {
apply plugin: 'org.jreleaser'
tasks["assembleDist"].doFirst {
// This is a workaround for a weird behavior.
// https://github.com/jreleaser/jreleaser/issues/1292
mkdir "$buildDir/jreleaser"
}

checksum {
individual = true
files = false
}

release {
github {
overwrite = true
tagName = '{{projectVersion}}'
changelog {
// For now, we won't have a changelog added to the release. In the future, we could create a changelog-snippet
// from the real changelog as part of a command hook prior to the release step
enabled = false
}
commitAuthor {
name = "smithy-automation"
email = "github-smithy-automation@amazon.com"
}
tasks["assembleDist"].dependsOn("runtimeZip")

jreleaser {
gitRootSearch = true
dryrun = false

project {
website = 'https://smithy.io'
authors = ['Smithy']
vendor = "Smithy"
license = 'Apache-2.0'
description = "Smithy CLI - A CLI for building, validating, querying, and iterating on Smithy models"
copyright = "2019"
}
}

files {
active = "ALWAYS"
artifact {
// We'll include the VERSION file in the release artifacts so that the version can be easily
// retrieving by hitting the GitHub `releases/latest` url
path = "../VERSION"
extraProperties.put('skipSigning', true)
checksum {
individual = true
files = false
}
}

platform {
// These replacements are for the names of files that are released, *not* for names within this build config
replacements = [
'osx': 'darwin',
'aarch_64': 'aarch64',
'windows_x86_64': 'windows_x64'
]
}

distributions {
smithy {
distributionType = 'JLINK'
stereotype = 'CLI'

artifact {
path = "build/image/smithy-cli-linux-x86_64.zip"
platform = "linux-x86_64"
}

artifact {
path = "build/image/smithy-cli-linux-aarch64.zip"
platform = "linux-aarch_64"
release {
github {
overwrite = true
tagName = '{{projectVersion}}'
changelog {
// For now, we won't have a changelog added to the release. In the future, we could create a changelog-snippet
// from the real changelog as part of a command hook prior to the release step
enabled = false
}
commitAuthor {
name = "smithy-automation"
email = "github-smithy-automation@amazon.com"
}
}
}

files {
active = "ALWAYS"
artifact {
path = "build/image/smithy-cli-darwin-x86_64.zip"
platform = "osx-x86_64"
// We'll include the VERSION file in the release artifacts so that the version can be easily
// retrieving by hitting the GitHub `releases/latest` url
path = "../VERSION"
extraProperties.put('skipSigning', true)
}
}

artifact {
path = "build/image/smithy-cli-darwin-aarch64.zip"
platform = "osx-aarch_64"
}
platform {
// These replacements are for the names of files that are released, *not* for names within this build config
replacements = [
'osx': 'darwin',
'aarch_64': 'aarch64',
'windows_x86_64': 'windows_x64'
]
}

artifact {
path = "build/image/smithy-cli-windows-x64.zip"
platform = "windows-x86_64"
distributions {
smithy {
distributionType = 'JLINK'
stereotype = 'CLI'

artifact {
path = "build/image/smithy-cli-linux-x86_64.zip"
platform = "linux-x86_64"
}

artifact {
path = "build/image/smithy-cli-linux-aarch64.zip"
platform = "linux-aarch_64"
}

artifact {
path = "build/image/smithy-cli-darwin-x86_64.zip"
platform = "osx-x86_64"
}

artifact {
path = "build/image/smithy-cli-darwin-aarch64.zip"
platform = "osx-aarch_64"
}

artifact {
path = "build/image/smithy-cli-windows-x64.zip"
platform = "windows-x86_64"
}
}
}
}

signing {
active = "RELEASE"
armored = true
verify = true
signing {
active = "RELEASE"
armored = true
verify = true
}
}
}

0 comments on commit 9106d59

Please sign in to comment.