Skip to content

Commit cb189cf

Browse files
committed
Introduce changelog report.
Introduce a tool to collect and update the changelog.txt file. Ensure that updating this report is part of the pre-checks before doing a release. Resolves #1295.
1 parent 593915c commit cb189cf

File tree

6 files changed

+1175
-0
lines changed

6 files changed

+1175
-0
lines changed

README.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Before you make a release, follow this checklist:
3636
* Are you using the latest milestone/release candidate/release of Spring Security? If not, upgrade. (Don't forget `spring-buildsnapshot` profile.)
3737
* Are you setup with the right version of Java? If not switch. (Java 17 for 4.0+, Java 8 for everything else.)
3838
* Is it time to switch from milestone to release candidate? Or from release candidate to release?
39+
* Have you closed this release's Github issue milestone, run `ChangeLogCreator` and updated `changelog.txt`?
3940

4041
NOTE: The _actual_ building and releasing is done on CI inside a Docker container, ensuring little risk between versions of Java.
4142
But part of the release process requires a local check, which DOES depend upon your environment.

docs.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
</formats>
88
<includeBaseDirectory>false</includeBaseDirectory>
99
<fileSets>
10+
<fileSet>
11+
<!--
12+
Adds readme and other textfiles to the root of the distribution archive.
13+
-->
14+
<directory>src/dist</directory>
15+
<includes>
16+
<include>changelog.txt</include>
17+
<include>license.txt</include>
18+
<include>notice.txt</include>
19+
<include>readme.txt</include>
20+
</includes>
21+
<outputDirectory />
22+
</fileSet>
1023
<fileSet>
1124
<!--
1225
Adds reference manual (html) to the distribution archive

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
<slf4j.version>2.0.3</slf4j.version>
114114
<smack.version>4.3.5</smack.version>
115115
<spring.version>6.0.0</spring.version>
116+
<spring-hateos.version>2.0.0</spring-hateos.version>
116117
<spring-security.version>6.0.0-RC1</spring-security.version>
117118
<sun-mail.version>2.0.1</sun-mail.version>
118119
<stax.version>2.0.1</stax.version>
@@ -553,6 +554,7 @@
553554
<plugin>
554555
<groupId>org.apache.maven.plugins</groupId>
555556
<artifactId>maven-resources-plugin</artifactId>
557+
<version>3.3.0</version>
556558
<executions>
557559
<execution>
558560
<id>copy-asciidoc-resources</id>

spring-ws-core/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@
205205
<scope>test</scope>
206206
</dependency>
207207

208+
<dependency>
209+
<groupId>org.springframework.hateoas</groupId>
210+
<artifactId>spring-hateoas</artifactId>
211+
<version>${spring-hateos.version}</version>
212+
<scope>test</scope>
213+
</dependency>
214+
<dependency>
215+
<groupId>org.springframework</groupId>
216+
<artifactId>spring-webflux</artifactId>
217+
<scope>test</scope>
218+
</dependency>
219+
208220
</dependencies>
209221

210222
<profiles>
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* Copyright 2005-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.ws.support;
17+
18+
import net.minidev.json.JSONArray;
19+
20+
import java.time.Duration;
21+
import java.time.LocalDate;
22+
import java.util.Iterator;
23+
import java.util.List;
24+
25+
import org.springframework.hateoas.IanaLinkRelations;
26+
import org.springframework.hateoas.Links;
27+
import org.springframework.http.HttpEntity;
28+
import org.springframework.http.HttpHeaders;
29+
import org.springframework.web.reactive.function.client.WebClient;
30+
31+
import com.jayway.jsonpath.JsonPath;
32+
33+
/**
34+
* Little helper to build a changelog from the tickets of a particular milestone.
35+
*
36+
* @author Oliver Gierke
37+
* @author Greg Turnquist
38+
*/
39+
class ChangelogCreator {
40+
41+
private static final int MILESTONE_ID = 91;
42+
private static final String URI_TEMPLATE = "https://api.github.com/repos/spring-projects/spring-ws/issues?milestone={id}&state=closed";
43+
44+
public static void main(String... args) {
45+
46+
/*
47+
* If you run into github rate limiting issues, you can always use a Github Personal Token by adding
48+
* {@code .header(HttpHeaders.AUTHORIZATION, "token your-github-token")} to the webClient call.
49+
*/
50+
51+
WebClient webClient = WebClient.create();
52+
53+
try {
54+
HttpEntity<String> response = webClient //
55+
.get().uri(URI_TEMPLATE, MILESTONE_ID) //
56+
// .header(HttpHeaders.AUTHORIZATION, "token <plugin in a personal token and uncomment>") //
57+
.exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) //
58+
.block(Duration.ofSeconds(10));
59+
60+
boolean keepChecking = true;
61+
boolean printHeader = true;
62+
63+
while (keepChecking) {
64+
65+
readPage(response.getBody(), printHeader);
66+
printHeader = false;
67+
68+
List<String> linksInHeader = response.getHeaders().get(HttpHeaders.LINK);
69+
Links links = linksInHeader == null ? Links.NONE : Links.parse(linksInHeader.get(0));
70+
71+
if (links.getLink(IanaLinkRelations.NEXT).isPresent()) {
72+
73+
response = webClient //
74+
.get().uri(links.getRequiredLink(IanaLinkRelations.NEXT).expand().getHref()) //
75+
.exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) //
76+
.block(Duration.ofSeconds(10));
77+
78+
} else {
79+
keepChecking = false;
80+
}
81+
}
82+
} catch (Exception e) {
83+
System.out.println("Couldn't retrieve MILESTONE " + MILESTONE_ID);
84+
}
85+
}
86+
87+
private static void readPage(String content, boolean header) {
88+
89+
JsonPath titlePath = JsonPath.compile("$[*].title");
90+
JsonPath idPath = JsonPath.compile("$[*].number");
91+
92+
JSONArray titles = titlePath.read(content);
93+
Iterator<Object> ids = ((JSONArray) idPath.read(content)).iterator();
94+
95+
if (header) {
96+
System.out.println(
97+
"Changes in version " + JsonPath.read(content, "$[0].milestone.title") + " (" + LocalDate.now() + ")");
98+
System.out.println("----------------------------------------");
99+
}
100+
101+
for (Object title : titles) {
102+
103+
String format = String.format("- #%s - %s", ids.next(), title.toString().replaceAll("`", ""));
104+
System.out.println(format.endsWith(".") ? format : format.concat("."));
105+
}
106+
}
107+
}

0 commit comments

Comments
 (0)