|
| 1 | +import java.io.FileWriter; |
| 2 | +import java.io.IOException; |
| 3 | +import java.nio.file.Files; |
| 4 | +import java.nio.file.Path; |
| 5 | +import java.nio.file.Paths; |
| 6 | + |
| 7 | +public class ReadmeUpdater { |
| 8 | + |
| 9 | + private static final Path README_PATH = Paths.get("../README.md"); |
| 10 | + private static final Path POM_PATH = Paths.get("../pom.xml"); |
| 11 | + |
| 12 | + public static void main(String[] args) throws IOException { |
| 13 | + String releaseVersion = args[0]; |
| 14 | + |
| 15 | + String newReadme = new String(Files.readAllBytes(README_PATH)) |
| 16 | + .replaceAll("<version>.*</version>", |
| 17 | + String.format("<version>%s</version>", releaseVersion)) |
| 18 | + .replaceAll("implementation 'com\\.featureprobe:server-sdk-java:.*'", |
| 19 | + String.format("implementation 'com.featureprobe:server-sdk-java:%s'", releaseVersion)); |
| 20 | + |
| 21 | + String newPom = new String(Files.readAllBytes(POM_PATH)) |
| 22 | + .replaceAll("<artifactId>server-sdk-java</artifactId>\n <version>.*</version>", |
| 23 | + String.format("<artifactId>server-sdk-java</artifactId>\n <version>%s</version>", releaseVersion)); |
| 24 | + |
| 25 | + try (FileWriter readme = new FileWriter(README_PATH.toString(), false); |
| 26 | + FileWriter pom = new FileWriter(POM_PATH.toString(), false)) { |
| 27 | + readme.write(newReadme); |
| 28 | + pom.write(newPom); |
| 29 | + } catch (IOException e) { |
| 30 | + throw e; |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | +} |
0 commit comments