diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishToSdkmanCommand.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishToSdkmanCommand.java index 61130106d5..1938610dc0 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishToSdkmanCommand.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishToSdkmanCommand.java @@ -64,8 +64,7 @@ public class PublishToSdkmanCommand implements Command { String version = nonOptionArgs.get(2); boolean makeDefault = false; if (nonOptionArgs.size() == 4) { - String releaseBranch = nonOptionArgs.get(3); - makeDefault = ("master".equals(releaseBranch)); + makeDefault = Boolean.parseBoolean(nonOptionArgs.get(3)); } this.service.publish(version, makeDefault); } diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sdkman/SdkmanService.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sdkman/SdkmanService.java index 099737353b..4064d7af13 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sdkman/SdkmanService.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sdkman/SdkmanService.java @@ -78,7 +78,7 @@ public class SdkmanService { private void makeDefault(String version) { logger.debug("Making this version the default"); Request request = new Request(version); - RequestEntity requestEntity = RequestEntity.post(URI.create(SDKMAN_URL + "default")) + RequestEntity requestEntity = RequestEntity.put(URI.create(SDKMAN_URL + "default")) .header(CONSUMER_KEY_HEADER, this.properties.getConsumerKey()) .header(CONSUMER_TOKEN_HEADER, this.properties.getConsumerToken()) .contentType(MediaType.APPLICATION_JSON).body(request); diff --git a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/PublishToSdkmanCommandTests.java b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/PublishToSdkmanCommandTests.java index a528f9522b..e612650bb1 100644 --- a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/PublishToSdkmanCommandTests.java +++ b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/PublishToSdkmanCommandTests.java @@ -51,42 +51,36 @@ class PublishToSdkmanCommandTests { @Test void runWhenReleaseTypeNotSpecifiedShouldThrowException() throws Exception { Assertions.assertThatIllegalStateException() - .isThrownBy(() -> this.command.run(new DefaultApplicationArguments("publishGradlePlugin"))); + .isThrownBy(() -> this.command.run(new DefaultApplicationArguments("publishToSdkman"))); } @Test void runWhenVersionNotSpecifiedShouldThrowException() throws Exception { Assertions.assertThatIllegalStateException() - .isThrownBy(() -> this.command.run(new DefaultApplicationArguments("publishGradlePlugin", "RELEASE"))); + .isThrownBy(() -> this.command.run(new DefaultApplicationArguments("publishToSdkman", "RELEASE"))); } @Test void runWhenReleaseTypeMilestoneShouldDoNothing() throws Exception { - this.command.run(new DefaultApplicationArguments("publishGradlePlugin", "M", "1.2.3")); + this.command.run(new DefaultApplicationArguments("publishToSdkman", "M", "1.2.3")); verifyNoInteractions(this.service); } @Test void runWhenReleaseTypeRCShouldDoNothing() throws Exception { - this.command.run(new DefaultApplicationArguments("publishGradlePlugin", "RC", "1.2.3")); + this.command.run(new DefaultApplicationArguments("publishToSdkman", "RC", "1.2.3")); verifyNoInteractions(this.service); } @Test - void runWhenBranchNotSpecifiedShouldCallServiceWithMakeDefaultFalse() throws Exception { + void runWhenLatestGANotSpecifiedShouldCallServiceWithMakeDefaultFalse() throws Exception { DefaultApplicationArguments args = new DefaultApplicationArguments("promote", "RELEASE", "1.2.3"); testRun(args, false); } - @Test - void runWhenBranchNotMasterShouldCallServiceWithMakeDefaultFalse() throws Exception { - DefaultApplicationArguments args = new DefaultApplicationArguments("promote", "RELEASE", "1.2.3", "other"); - testRun(args, false); - } - @Test void runWhenReleaseTypeReleaseShouldCallService() throws Exception { - DefaultApplicationArguments args = new DefaultApplicationArguments("promote", "RELEASE", "1.2.3", "master"); + DefaultApplicationArguments args = new DefaultApplicationArguments("promote", "RELEASE", "1.2.3", "true"); testRun(args, true); } diff --git a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sdkman/SdkmanServiceTests.java b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sdkman/SdkmanServiceTests.java index 4b78555143..d7a9e7d4d5 100644 --- a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sdkman/SdkmanServiceTests.java +++ b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sdkman/SdkmanServiceTests.java @@ -59,8 +59,8 @@ class SdkmanServiceTests { void publishWhenMakeDefaultTrue() throws Exception { setupExpectation("https://vendors.sdkman.io/release", "{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"url\": \"https://repo.spring.io/simple/libs-release-local/org/springframework/boot/spring-boot-cli/1.2.3/spring-boot-cli-1.2.3-bin.zip\"}"); - setupExpectation("https://vendors.sdkman.io/default", - "{\"candidate\": \"springboot\", \"version\": \"1.2.3\"}"); + setupExpectation("https://vendors.sdkman.io/default", "{\"candidate\": \"springboot\", \"version\": \"1.2.3\"}", + HttpMethod.PUT); setupExpectation("https://vendors.sdkman.io/announce/struct", "{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"hashtag\": \"springboot\"}"); this.service.publish("1.2.3", true); @@ -78,7 +78,11 @@ class SdkmanServiceTests { } private void setupExpectation(String url, String body) { - this.server.expect(requestTo(url)).andExpect(method(HttpMethod.POST)).andExpect(content().json(body)) + setupExpectation(url, body, HttpMethod.POST); + } + + private void setupExpectation(String url, String body, HttpMethod method) { + this.server.expect(requestTo(url)).andExpect(method(method)).andExpect(content().json(body)) .andExpect(header("Consumer-Key", "sdkman-consumer-key")) .andExpect(header("Consumer-Token", "sdkman-consumer-token")) .andExpect(header("Content-Type", MediaType.APPLICATION_JSON.toString())).andRespond(withSuccess()); diff --git a/ci/pipeline.yml b/ci/pipeline.yml index d69b969eed..92dfb18c57 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -613,6 +613,7 @@ jobs: <<: *sdkman-task-params RELEASE_TYPE: RELEASE BRANCH: ((branch)) + LATEST_GA: false groups: - name: "builds" jobs: ["build", "jdk11-build", "jdk15-build", "windows-build"] diff --git a/ci/scripts/publish-to-sdkman.sh b/ci/scripts/publish-to-sdkman.sh index 7373a4baa8..00bb6adc26 100755 --- a/ci/scripts/publish-to-sdkman.sh +++ b/ci/scripts/publish-to-sdkman.sh @@ -4,6 +4,6 @@ source $(dirname $0)/common.sh version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) -java -jar /spring-boot-release-scripts.jar publishToSdkman $RELEASE_TYPE $version $BRANCH || { exit 1; } +java -jar /spring-boot-release-scripts.jar publishToSdkman $RELEASE_TYPE $version $LATEST_GA || { exit 1; } echo "Push to SDKMAN complete" diff --git a/ci/tasks/publish-to-sdkman.yml b/ci/tasks/publish-to-sdkman.yml index f9a07566ea..0215e2943b 100755 --- a/ci/tasks/publish-to-sdkman.yml +++ b/ci/tasks/publish-to-sdkman.yml @@ -6,6 +6,7 @@ inputs: params: RELEASE_TYPE: BRANCH: + LATEST_GA: SDKMAN_CONSUMER_KEY: SDKMAN_CONSUMER_TOKEN: run: