mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Fix detection of latest GA for SDKMAN
Fixes gh-24475
This commit is contained in:
parent
60f526add0
commit
822ae0daf7
@ -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);
|
||||
}
|
||||
|
@ -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<Request> requestEntity = RequestEntity.post(URI.create(SDKMAN_URL + "default"))
|
||||
RequestEntity<Request> 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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -693,6 +693,7 @@ jobs:
|
||||
<<: *sdkman-task-params
|
||||
RELEASE_TYPE: RELEASE
|
||||
BRANCH: ((branch))
|
||||
LATEST_GA: false
|
||||
groups:
|
||||
- name: "builds"
|
||||
jobs: ["build", "jdk11-build", "jdk15-build", "windows-build"]
|
||||
|
@ -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"
|
||||
|
@ -6,6 +6,7 @@ inputs:
|
||||
params:
|
||||
RELEASE_TYPE:
|
||||
BRANCH:
|
||||
LATEST_GA:
|
||||
SDKMAN_CONSUMER_KEY:
|
||||
SDKMAN_CONSUMER_TOKEN:
|
||||
run:
|
||||
|
Loading…
Reference in New Issue
Block a user