Skip to content

Commit

Permalink
Publish ktlint cli signature to Github release.
Browse files Browse the repository at this point in the history
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
  • Loading branch information
Tapchicoma committed Sep 11, 2020
1 parent 1952eb7 commit 17b27cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Do not report when string-template expression is a keyword ([#883](https://github.com/pinterest/ktlint/issues/883))
- False positive for subclass imports in `no-unused-imports` ([#845](https://github.com/pinterest/ktlint/issues/845))
- False positive for static java function imports in `no-unused-imports` ([#872](https://github.com/pinterest/ktlint/issues/872))
- Missing signature for KtLint CLI artifact published to Github release ([#895](https://github.com/pinterest/ktlint/issues/895))

### Changed
- `Ktlint` object internal code cleanup
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/ktlint-publication.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ publishing {
* ```
*/
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
//useGpgCmd()

sign(publishing.publications["maven"])
setRequired({
!version.toString().endsWith("SNAPSHOT")
Expand Down
13 changes: 10 additions & 3 deletions ktlint/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'ktlint-publication'
id 'com.github.johnrengelman.shadow'
id 'org.gradle.crypto.checksum'
id 'signing'
}

jar {
Expand Down Expand Up @@ -47,15 +48,21 @@ def shadowJarExecutableTask = tasks.register("shadowJarExecutable", DefaultTask.
group = "Distribution"

inputs.files tasks.named("shadowJar")
outputs.file "$buildDir/run/ktlint"
outputs.files("$buildDir/run/ktlint")
if (!version.toString().endsWith("SNAPSHOT")) {
outputs.files("$buildDir/run/ktlint.asc")
}

doLast {
File execFile = outputs.files.singleFile
File execFile = outputs.files.getFiles().first()
execFile.withOutputStream {
it.write "#!/bin/sh\n\nexec java -Xmx512m -jar \"\$0\" \"\$@\"\n\n".bytes
it.write inputs.files.singleFile.bytes
}
execFile.setExecutable(true, false)
if (!version.toString().endsWith("SNAPSHOT")) {
signing.sign(execFile)
}
}
finalizedBy tasks.named("shadowJarExecutableChecksum")
}
Expand All @@ -66,7 +73,7 @@ tasks.register("shadowJarExecutableChecksum", Checksum.class) {

files = shadowJarExecutableTask.get().outputs.files
// put the checksums in the same folder with the executable itself
outputDir = shadowJarExecutableTask.get().outputs.files.singleFile.parentFile
outputDir = shadowJarExecutableTask.get().outputs.files.getFiles().first().parentFile

algorithm = Checksum.Algorithm.MD5
}

0 comments on commit 17b27cf

Please sign in to comment.