Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void execute() {

updateNextVersion(gradlePropertiesFile, properties, newVersion);
updateChangelog(currentVersion);
updateSetupDoc(currentVersion);

createPullRequestWithChanges(currentVersion);
setGitHubRelease(currentVersion, releaseTag);
Expand Down Expand Up @@ -85,12 +86,23 @@ private void updateNextVersion(File gradlePropertiesFile, Properties properties,

private void updateChangelog(String newVersion) {
log("Updating changelog with version: " + newVersion);
Path changelogPath = getChangelogPath();
Path changelogPath = getProjectPath("CHANGELOG.asciidoc");
String contents = getContents(changelogPath);
contents = uncommentNextRelease(contents);
replaceFileContents(changelogPath, resolvePlaceholders(contents, newVersion));
}

private void updateSetupDoc(String currentVersion) {
log("Updating setup doc to show version: " + currentVersion);
Path setupDocPath = getProjectPath("docs/setup.asciidoc");
String contents = getContents(setupDocPath);
Pattern versionMentionsPattern = Pattern.compile("(?<=co\\.elastic\\.apm\\.android/)\\d+\\.\\d+\\.\\d+|(?<=co\\.elastic\\.apm:android-sdk:)\\d+\\.\\d+\\.\\d+|(?<=id\\s\"co\\.elastic\\.apm\\.android\"\\sversion\\s\")\\d+\\.\\d+\\.\\d+");
Matcher versionMentionMatcher = versionMentionsPattern.matcher(contents);

String setupDocWithNewVersion = versionMentionMatcher.replaceAll(currentVersion);
replaceFileContents(setupDocPath, setupDocWithNewVersion.getBytes(StandardCharsets.UTF_8));
}

private byte[] resolvePlaceholders(String text, String newVersion) {
Map<String, String> substitutions = new HashMap<>();
substitutions.put("release_date", new SimpleDateFormat("yyyy/MM/dd", Locale.US).format(new Date()));
Expand All @@ -100,8 +112,8 @@ private byte[] resolvePlaceholders(String text, String newVersion) {
return substitutor.replace(text).getBytes(StandardCharsets.UTF_8);
}

private Path getChangelogPath() {
File changelog = new File("CHANGELOG.asciidoc");
private Path getProjectPath(String relativePath) {
File changelog = new File(relativePath);
return changelog.toPath();
}

Expand Down