Skip to content

Commit 6341ac7

Browse files
Add runtime plugin for generating stand-alone images (#159)
* add runtime plugin for generating stand-alone images * add JReleaser configuration for github release and runtimes * Use runtime plugin fork Updates the runtime plugin to a fork with support for java 21, instead of the upstream https://github.com/beryx/badass-runtime-plugin. See beryx/badass-runtime-plugin#154 for more details. Also changed the java version back to 21. * Remove deploy github workflow We had a github workflow that would run on a tag push, creating a new release and uploading a zip of the language server. Jreleaser should take care of all that now, so the workflow is unnecessary. * Add changelog to github release notes So we don't have to manually add the release notes to the github release after it is published. I added a custom task to read in the full changelog, and parse out the entry for the latest version. The result is written out to a resources file that I pointed the github release config to. The jreleaser docs don't seem to be 100% clear on whether the changelog is actually what ends up in the release notes, but it would make sense to me, and the text in https://jreleaser.org/guide/latest/reference/release/github.html#_release_notes suggests it. --------- Co-authored-by: Miles Ziemer <[email protected]>
1 parent a47284a commit 6341ac7

File tree

2 files changed

+144
-52
lines changed

2 files changed

+144
-52
lines changed

.github/workflows/deploy.yml

-36
This file was deleted.

build.gradle

+144-16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
1717
import org.gradle.api.tasks.testing.logging.TestLogEvent
1818

19+
import java.util.regex.Pattern
1920

2021
buildscript {
2122
repositories {
@@ -33,10 +34,13 @@ plugins {
3334
id "application"
3435

3536
id "maven-publish"
36-
id "signing"
3737
id "com.palantir.git-version" version "0.12.3"
3838
id "checkstyle"
3939
id "org.jreleaser" version "1.13.0"
40+
41+
// Fork of runtime plugin with java 21 support, until https://github.com/beryx/badass-runtime-plugin/issues/153
42+
// is resolved.
43+
id "com.dua3.gradle.runtime" version "1.13.1-patch-1"
4044
}
4145

4246

@@ -69,6 +73,8 @@ task javadocJar(type: Jar) {
6973
ext {
7074
// Load the Smithy Language Server version from VERSION.
7175
libraryVersion = project.file("VERSION").getText('UTF-8').replace(System.lineSeparator(), "")
76+
imageJreVersion = "21"
77+
correttoRoot = "https://corretto.aws/downloads/latest/amazon-corretto-${imageJreVersion}"
7278
}
7379

7480
println "Smithy Language Server version: '${libraryVersion}'"
@@ -78,7 +84,6 @@ def stagingDirectory = rootProject.layout.buildDirectory.dir("staging")
7884
allprojects {
7985
apply plugin: "java"
8086
apply plugin: "maven-publish"
81-
apply plugin: "signing"
8287
group = "software.amazon.smithy"
8388
version = libraryVersion
8489
description = "Language Server Protocol implementation for Smithy"
@@ -228,31 +233,154 @@ jar {
228233
}
229234
}
230235

236+
237+
runtime {
238+
addOptions("--compress", "2", "--strip-debug", "--no-header-files", "--no-man-pages")
239+
addModules("java.logging")
240+
241+
launcher {
242+
jvmArgs = [
243+
'-XX:-UsePerfData',
244+
'-Xshare:auto',
245+
'-XX:SharedArchiveFile={{BIN_DIR}}/../lib/smithy.jsa'
246+
]
247+
}
248+
249+
targetPlatform("linux-x86_64") {
250+
jdkHome = jdkDownload("${correttoRoot}-x64-linux-jdk.tar.gz")
251+
}
252+
253+
targetPlatform("linux-aarch64") {
254+
jdkHome = jdkDownload("${correttoRoot}-aarch64-linux-jdk.tar.gz")
255+
}
256+
257+
targetPlatform("darwin-x86_64") {
258+
jdkHome = jdkDownload("${correttoRoot}-x64-macos-jdk.tar.gz")
259+
}
260+
261+
targetPlatform("darwin-aarch64") {
262+
jdkHome = jdkDownload("${correttoRoot}-aarch64-macos-jdk.tar.gz")
263+
}
264+
265+
targetPlatform("windows-x64") {
266+
jdkHome = jdkDownload("${correttoRoot}-x64-windows-jdk.zip")
267+
}
268+
269+
// Because we're using target-platforms, it will use this property as a prefix for each target zip
270+
imageZip = layout.buildDirectory.file("image/smithy-language-server.zip")
271+
}
272+
273+
tasks["assembleDist"].dependsOn("publish")
274+
tasks["assembleDist"].dependsOn("runtimeZip")
275+
276+
// Generate a changelog that only includes the changes for the latest version
277+
// which Jreleaser will add to the release notes of the github release.
278+
def releaseChangelogFile = project.layout.buildDirectory.file("resources/RELEASE_CHANGELOG.md").get().asFile
279+
tasks.register("createReleaseChangelog") {
280+
dependsOn processResources
281+
282+
doLast {
283+
def changelog = project.file("CHANGELOG.md").text
284+
// Copy the text in between the first two version headers
285+
def matcher = Pattern.compile("^## \\d+\\.\\d+\\.\\d+", Pattern.MULTILINE).matcher(changelog)
286+
def getIndex = {
287+
matcher.find()
288+
return matcher.start()
289+
}
290+
def result = changelog.substring(getIndex(), getIndex()).trim()
291+
releaseChangelogFile.write(result)
292+
}
293+
}
294+
295+
tasks.jreleaserRelease.dependsOn(tasks.createReleaseChangelog)
296+
231297
jreleaser {
232298
dryrun = false
233299

234-
// Used for creating a tagged release, uploading files and generating changelog.
235-
// In the future we can set this up to push release tags to GitHub, but for now it's
236-
// set up to do nothing.
237-
// https://jreleaser.org/guide/latest/reference/release/index.html
300+
project {
301+
website = 'https://smithy.io'
302+
authors = ['Smithy']
303+
vendor = "Smithy"
304+
license = 'Apache-2.0'
305+
description = "Smithy Language Server - A Language Server Protocol implementation for the Smithy IDL."
306+
copyright = "2019"
307+
}
308+
238309
release {
239-
generic {
240-
enabled = true
241-
skipRelease = true
310+
github {
311+
overwrite = true
312+
tagName = '{{projectVersion}}'
313+
releaseName = 'Smithy Language Server v{{{projectVersion}}}'
314+
changelog {
315+
external = releaseChangelogFile.absolutePath
316+
}
317+
commitAuthor {
318+
name = "smithy-automation"
319+
320+
}
242321
}
243322
}
244323

245-
// Used to announce a release to configured announcers.
246-
// https://jreleaser.org/guide/latest/reference/announce/index.html
247-
announce {
248-
active = "NEVER"
324+
files {
325+
active = "ALWAYS"
326+
artifact {
327+
// We'll include the VERSION file in the release artifacts so that the version can be easily
328+
// retrieving by hitting the GitHub `releases/latest` url
329+
path = "VERSION"
330+
extraProperties.put('skipSigning', true)
331+
}
332+
}
333+
334+
platform {
335+
// These replacements are for the names of files that are released, *not* for names within this build config
336+
replacements = [
337+
'osx': 'darwin',
338+
'aarch_64': 'aarch64',
339+
'windows_x86_64': 'windows_x64'
340+
]
341+
}
342+
343+
distributions {
344+
'smithy-language-server' {
345+
distributionType = 'JLINK'
346+
stereotype = 'CLI'
347+
348+
artifact {
349+
path = "build/image/smithy-language-server-linux-x86_64.zip"
350+
platform = "linux-x86_64"
351+
}
352+
353+
artifact {
354+
path = "build/image/smithy-language-server-linux-aarch64.zip"
355+
platform = "linux-aarch_64"
356+
}
357+
358+
artifact {
359+
path = "build/image/smithy-language-server-darwin-x86_64.zip"
360+
platform = "osx-x86_64"
361+
}
362+
363+
artifact {
364+
path = "build/image/smithy-language-server-darwin-aarch64.zip"
365+
platform = "osx-aarch_64"
366+
}
367+
368+
artifact {
369+
path = "build/image/smithy-language-server-windows-x64.zip"
370+
platform = "windows-x86_64"
371+
}
372+
}
373+
}
374+
375+
checksum {
376+
individual = true
377+
files = false
249378
}
250379

251-
// Signing configuration.
252-
// https://jreleaser.org/guide/latest/reference/signing.html
253380
signing {
254-
active = "ALWAYS"
381+
active = "RELEASE"
255382
armored = true
383+
verify = true
256384
}
257385

258386
// Configuration for deploying to Maven Central.

0 commit comments

Comments
 (0)