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 150bcd6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 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: 11 additions & 2 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,23 @@ def shadowJarExecutableTask = tasks.register("shadowJarExecutable", DefaultTask.
group = "Distribution"

inputs.files tasks.named("shadowJar")
outputs.file "$buildDir/run/ktlint"
outputs.files(
"$buildDir/run/ktlint",
"$buildDir/run/ktlint.asc",
)

logger.warn("Signatory: ${signing.signatories}")

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 Down

0 comments on commit 150bcd6

Please sign in to comment.