Skip to content

Commit

Permalink
Add jreleaser config
Browse files Browse the repository at this point in the history
This commit both sets up general configuration as well as
includes initial support for homebrew

Bug #82
  • Loading branch information
bitspittle committed Jan 25, 2022
1 parent fcd152d commit 0f44fe4
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,20 @@ https://user-images.githubusercontent.com/43705986/135570277-2d67033a-f647-4b04-

# Trying it out yourself

The first step is to get the Kobweb binary. You can download it or build it, so we'll include instructions for both
approaches.
The first step is to get the Kobweb binary. You can install it, download it, build it, so we'll include instructions for
all these approaches.

## Install the Kobweb binary

*Major thanks to [aalmiray](https://github.com/aalmiray) and [helpermethod](https://github.com/helpermethod) to helping
me get these installation options working. Check out [JReleaser](https://github.com/jreleaser/jreleaser) if you ever
need to do this in your own project!*

### Homebrew

```bash
$ brew install varabyte/tap/kobweb
```

## Download the Kobweb binary

Expand Down
77 changes: 77 additions & 0 deletions cli/kobweb/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import org.jreleaser.model.Active

plugins {
kotlin("jvm")
kotlin("plugin.serialization")
application
alias(libs.plugins.jreleaser)
}

group = "com.varabyte.kobweb.cli"
Expand All @@ -26,4 +29,78 @@ application {
// Avoid ambiguity / add clarity in generated artifacts
tasks.jar {
archiveFileName.set("kobweb-cli.jar")
}

// Read about JReleaser at https://jreleaser.org/guide/latest/index.html
jreleaser {
dryrun.set(false) // Specified explicitly for convenience - set dryrun to true when experimenting with values!
gitRootSearch.set(true)
project {
website.set("https://kobweb.varabyte.com/")
docsUrl.set("https://kobweb.varabyte.com/docs")
description.set("Kobweb CLI provides commands to handle the tedious parts of building a Compose for Web app")
longDescription.set("""
Kobweb CLI provides commands to handle the tedious parts of building a Compose for Web app, including
project setup and configuration.
""".trimIndent())
authors.set(listOf("David Herman"))
license.set("Apache-2.0")
copyright.set("Copyright © 2022 Varabyte. All rights reserved.")
}
release {
github {
owner.set("varabyte")
tagName.set("cli-v{{projectVersion}}")

// Tags and releases are handled manually via the GitHub UI for now. TODO(#104)
skipTag.set(true)
skipRelease.set(true)

overwrite.set(true)
uploadAssets.set(Active.RELEASE)
commitAuthor {
name.set("David Herman")
email.set("bitspittle@gmail.com")
}
changelog {
enabled.set(false)
}
milestone {
// milestone management handled manually for now
close.set(false)
}
prerelease {
enabled.set(false)
}

// These values are specified in ~/.gradle/gradle.properties; otherwise sorry, no jreleasing for you :P
mapOf<String, (String) -> Unit>(
"varabyte.github.username" to { username.set(it) },
"varabyte.github.token" to { token.set(it) },
).forEach { (key, setter) ->
(findProperty(key) as? String)?.let { setter(it) } ?: run {
println("\"$key\" is missing so disabling github release")
enabled.set(false)
}
}
}
}
packagers {
brew {
active.set(Active.RELEASE)
// Redundant downloadUrl temporarily required. See https://github.com/jreleaser/jreleaser/issues/699
downloadUrl.set("https://{{repoHost}}/{{repoOwner}}/{{repoName}}/releases/download/{{tagName}}/{{artifactFile}}")
templateDirectory.set(File("jreleaser/templates/brew"))
}
}

distributions {
create("kobweb") {
listOf("zip", "tar").forEach { artifactExtension ->
artifact {
setPath("build/distributions/{{distributionName}}-{{projectVersion}}.$artifactExtension")
}
}
}
}
}
17 changes: 17 additions & 0 deletions cli/kobweb/jreleaser/templates/brew/README.md.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Homebrew Tap

This project is a list of formulae for exposing Varabyte artifacts to Homebrew.

## Formulae
Install a formula either by listing the tap path explicitly:

```sh
$ brew install varabyte/tap/<formula>
```

Or by installing our tap first:

```sh
$ brew tap varabyte/tap # you only need to do this the first time
$ brew install <formula>
```
30 changes: 30 additions & 0 deletions cli/kobweb/jreleaser/templates/brew/formula.rb.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# {{jreleaserCreationStamp}}
class {{brewFormulaName}} < Formula
desc "{{projectDescription}}"
homepage "{{projectWebsite}}"
url "{{distributionUrl}}"
version "{{projectVersion}}"
sha256 "{{distributionChecksumSha256}}"
license "{{projectLicense}}"

{{#brewHasLivecheck}}
livecheck do
{{#brewLivecheck}}
{{.}}
{{/brewLivecheck}}
end
{{/brewHasLivecheck}}
{{#brewDependencies}}
depends_on {{.}}
{{/brewDependencies}}

def install
libexec.install Dir["*"]
bin.install_symlink "#{libexec}/bin/{{distributionExecutable}}"
end

test do
output = shell_output("#{bin}/{{distributionExecutable}} version")
assert_match "{{projectVersion}}", output
end
end
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cdt="4.0.0" # chrome-developer-toolkit
commonmark = "0.18.0"
compose = "1.0.0"
freemarker = "2.3.31"
jreleaser = "1.0.0-M1"
jgit = "5.12.0.202106070339-r"
jsoup = "1.14.3"
kaml = "0.35.3"
Expand Down Expand Up @@ -53,6 +54,7 @@ ktor = ["ktor-server-core", "ktor-serialization", "ktor-auth", "ktor-server-host

[plugins]
jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose" }
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
Expand Down

0 comments on commit 0f44fe4

Please sign in to comment.