Skip to content

Commit 4b2723b

Browse files
committed
Simplify and improve build configuraton.
1 parent 55c4a95 commit 4b2723b

File tree

3 files changed

+20
-39
lines changed

3 files changed

+20
-39
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ jobs:
1313
- uses: actions/checkout@v2
1414
- name: Run tests
1515
run: ./gradlew clean test --info
16-
- name: Generate build number
17-
id: buildnumber
18-
uses: einaregilsson/build-number@v3
19-
with:
20-
token: ${{secrets.GITHUB_TOKEN}}
2116
- name: Set github tag
2217
id: vars
2318
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
19+
- name: Set short git hash
20+
id: vars
21+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
2422
- name: Build artifacts
25-
run: ./gradlew -Penv=production -Prelease=${{ steps.vars.outputs.tag }} -PbuildNumber=${{ steps.buildnumber.outputs.build_number }} clean assemble
23+
run: ./gradlew -Penv=production -Prelease=${{ steps.vars.outputs.tag }} -Phash=${{ steps.vars.outputs.sha_short }} clean assemble
2624
- uses: ncipollo/release-action@v1
2725
with:
2826
artifacts: "build/distributions/sdkman-cli-*.zip"

build.gradle

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,22 @@ ext.installBinDir = "${userHome}/.sdkman/bin"
1111
ext.installSrcDir = "${userHome}/.sdkman/src"
1212
ext.installContribDir = "${userHome}/.sdkman/contrib"
1313

14-
def loadConfiguration() {
15-
def environment = hasProperty('env') ? env : 'local'
16-
ext.environment = environment
17-
println("Environment is set to: ${environment}")
18-
19-
def buildNumber = hasProperty('buildNumber') ? buildNumber : '0'
20-
ext.buildNumber = buildNumber
21-
println("Build number set to: ${buildNumber}")
22-
23-
def release = hasProperty('release') ? release : 'master'
24-
ext.release = release
25-
println("Release set to: ${release}")
26-
27-
def configFile = file('config.groovy')
28-
def config = new ConfigSlurper(environment).parse(configFile.toURI().toURL())
29-
ext.config = config
30-
}
14+
ext.environment = hasProperty('env') ? env : 'local'
15+
ext.hash = hasProperty('hash') ? hash : 'hash'
16+
ext.release = hasProperty('release') ? release : 'master'
17+
ext.candidatesApi = ext.environment == 'production' ? 'https://api.sdkman.io/2' : 'http://localhost:8080/2'
3118

32-
loadConfiguration()
19+
ext.sdkmanVersion = ext.release == 'master' ? "master+${ext.hash}".toString() : ext.release
3320

34-
ext.sdkmanCliBuildVersion = ext.release == 'master' ? "master+${buildNumber}".toString() : ext.release
21+
println("Environment is set to: $environment")
22+
println("Short git hash: $hash")
23+
println("Release set to: $release")
24+
println("Candidtes API: $candidatesApi")
25+
println("Version: $sdkmanVersion")
3526

36-
repositories.jcenter()
27+
repositories {
28+
mavenCentral()
29+
}
3730

3831
dependencies {
3932
testImplementation('com.github.tomakehurst:wiremock:2.25.1') {
@@ -60,8 +53,8 @@ task prepareScripts(type: Copy) {
6053
filter(
6154
ReplaceTokens,
6255
tokens: [
63-
SDKMAN_VERSION : sdkmanCliBuildVersion,
64-
SDKMAN_CANDIDATES_API: config.candidatesApi
56+
SDKMAN_VERSION : sdkmanVersion,
57+
SDKMAN_CANDIDATES_API: candidatesApi
6558
]
6659
)
6760
}
@@ -77,8 +70,7 @@ tasks.test.configure {
7770
}
7871

7972
task assembleArchive(type: Zip, dependsOn: [prepareScripts, prepareContrib]) {
80-
archiveAppendix = 'cli'
81-
archiveVersion = sdkmanCliBuildVersion
73+
archiveVersion = sdkmanVersion
8274
from('build/scripts') {
8375
include('*.sh*')
8476
}

config.groovy

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)