-
-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Homebrew formula template * Add brew packager * Remove selfupdate functionality when installed via Homebrew * Configure JRELEASER_HOMEBREW_GITHUB_TOKEN * Order configuration alphabetically
- Loading branch information
1 parent
65ee538
commit f61702c
Showing
8 changed files
with
173 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SDKMAN! Homebrew Tap | ||
|
||
A Homebrew tap containing the Formula for the SDKMAN! CLI. | ||
|
||
## Installation | ||
|
||
```sh | ||
$ brew tap sdkman/tap | ||
$ brew install sdkman | ||
``` | ||
|
||
After successful installation add the following lines to the end of your `.bash_profile` | ||
|
||
```sh | ||
export SDKMAN_DIR=$(brew --prefix sdkman)/libexec | ||
[[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh" | ||
``` | ||
|
||
Open a new terminal and type | ||
|
||
```sh | ||
sdk version | ||
``` | ||
|
||
The output should look similar to this | ||
|
||
```sh | ||
SDKMAN {{version}} | ||
``` |
35 changes: 35 additions & 0 deletions
35
src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class {{brewFormulaName}} < Formula | ||
desc "{{projectDescription}}" | ||
homepage "{{projectWebsite}}" | ||
url "{{distributionUrl}}" | ||
version "{{projectVersion}}" | ||
sha256 "{{distributionChecksumSha256}}" | ||
license "{{projectLicense}}" | ||
|
||
def install | ||
libexec.install Dir["*"] | ||
|
||
%w[tmp ext etc var archives candidates].each { |dir| mkdir libexec/dir } | ||
|
||
system "curl", "-s", "https://api.sdkman.io/2/candidates/all", "-o", libexec/"var/candidates" | ||
|
||
(libexec/"etc/config").write <<~EOS | ||
sdkman_auto_answer=false | ||
sdkman_auto_complete=true | ||
sdkman_auto_env=false | ||
sdkman_auto_update=false | ||
sdkman_beta_channel=false | ||
sdkman_colour_enable=true | ||
sdkman_curl_connect_timeout=7 | ||
sdkman_curl_max_time=10 | ||
sdkman_debug_mode=false | ||
sdkman_insecure_ssl=false | ||
sdkman_rosetta2_compatible=false | ||
sdkman_selfupdate_feature=false | ||
EOS | ||
end | ||
|
||
test do | ||
assert_match {{projectVersion}}, shell_output("export SDKMAN_DIR=#{libexec} && source #{libexec}/bin/sdkman-init.sh && sdk version") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package sdkman.specs | ||
|
||
import sdkman.support.SdkmanEnvSpecification | ||
|
||
import java.time.Instant | ||
|
||
import static java.time.temporal.ChronoUnit.DAYS | ||
|
||
class SelfupdateSpec extends SdkmanEnvSpecification { | ||
static final String CANDIDATES_API = "http://localhost:8080/2" | ||
static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" | ||
static final String VERSION_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" | ||
|
||
def setup() { | ||
curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") | ||
curlStub.primeWith(VERSION_ENDPOINT, "echo 5.0.0") | ||
} | ||
|
||
def "should list selfupdate as a valid command when the selfupdate feature is toggled on"() { | ||
given: | ||
bash = sdkmanBashEnvBuilder | ||
.withConfiguration("sdkman_selfupdate_feature", selfUpdateFeature) | ||
.build() | ||
|
||
bash.start() | ||
bash.execute("source $bootstrapScript") | ||
|
||
when: | ||
bash.execute("sdk help") | ||
|
||
then: | ||
verifyOutput(bash.output) | ||
|
||
where: | ||
selfUpdateFeature | verifyOutput | ||
"false" | { !it.contains("selfupdate") } | ||
"true" | { it.contains("selfupdate") } | ||
} | ||
|
||
def "should source sdkman-selfupdate.sh when the selfupdate feature is toggled on"() { | ||
given: | ||
bash = sdkmanBashEnvBuilder | ||
.withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) | ||
.build() | ||
|
||
bash.start() | ||
bash.execute("source $bootstrapScript") | ||
|
||
when: | ||
bash.execute("sdk selfupdate") | ||
|
||
then: | ||
verifyOutput(bash.output) | ||
|
||
where: | ||
selfupdateFeature | verifyOutput | ||
"false" | { it.contains("Invalid command: selfupdate") } | ||
"true" | { it.contains("No update available at this time.") } | ||
} | ||
|
||
def "should perform an autoupdate when the selfupdate feature is toggled on and autoupdate is enabled"() { | ||
given: | ||
new File("$sdkmanDotDirectory/var/delay_upgrade").with { | ||
parentFile.mkdirs() | ||
createNewFile() | ||
lastModified = Instant.now().minus(2, DAYS).toEpochMilli() | ||
} | ||
|
||
bash = sdkmanBashEnvBuilder | ||
.withSdkmanVersion("4.0.0") | ||
.withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) | ||
.withConfiguration("sdkman_auto_update", autoUpdateEnabled) | ||
.withConfiguration("sdkman_auto_answer", "true") | ||
.build() | ||
|
||
bash.start() | ||
bash.execute("source $bootstrapScript") | ||
|
||
when: | ||
bash.execute("sdk version") | ||
|
||
then: | ||
verifyOutput(bash.output) | ||
|
||
where: | ||
selfupdateFeature | autoUpdateEnabled | verifyOutput | ||
"true" | "true" | { it.contains("ATTENTION: A new version of SDKMAN is available...") } | ||
"true" | "false" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } | ||
"false" | "true" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } | ||
} | ||
} |