Skip to content

Commit

Permalink
Fix updateReadme script
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Nov 26, 2024
1 parent 0e896b3 commit d6823ed
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions .github/updateReadme.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
class updateReadme {

public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.err.println("Usage: 'jbang updateReadme.java oldVersion newVersion'");
if (args.length != 1) {
System.err.println("Usage: 'jbang updateReadme.java newVersion'");
System.exit(1);
} else {
String oldVersion = args[0];
String newVersion = args[1];
String newVersion = args[0];

Path readmePath = Path.of("README.md");

String oldContent = Files.readString(readmePath, StandardCharsets.UTF_8);
String newContent = oldContent.replace(oldVersion, newVersion);
String newContent = oldContent.replaceAll("(?s)<version[^>]*>.*?</version>", "<version>" + newVersion + "</version>");
Files.write(readmePath, newContent.getBytes(StandardCharsets.UTF_8));
}
}
Expand Down

0 comments on commit d6823ed

Please sign in to comment.