Added SetVersion script, and updated versions to 1.0.1.

This commit is contained in:
Andrew Lalis 2024-01-04 21:44:45 -05:00
parent 017e01a935
commit ceddc49adf
5 changed files with 57 additions and 4 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.andrewlalis</groupId>
<artifactId>perfin</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>

53
scripts/SetVersion.java Normal file
View File

@ -0,0 +1,53 @@
import java.io.*;
import java.nio.file.*;
import java.util.*;
/**
* Utility script that updates the program's version in the many places where
* it's used, as opposed to making a fancy system to introspect the POM to get
* the version. Simply call <code>java scripts/SetVersion.java &lt;your version here&gt;</code>
* and it'll update all the necessary files.
*/
class SetVersion {
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.out.println("Missing required version argument.");
System.exit(1);
}
String version = args[0].strip();
System.out.println("Setting application to version " + version + " Is this okay? (yes/no)");
var reader = new BufferedReader(new InputStreamReader(System.in));
String response = reader.readLine();
if (!response.equalsIgnoreCase("yes")) {
System.out.println("Exiting.");
System.exit(1);
}
replaceInFile(
Path.of("scripts", "package-linux-deb.sh"),
"--app-version .* \\\\",
"--app-version \"" + version + "\" \\\\"
);
replaceInFile(
Path.of("scripts", "package-windows-msi.ps1"),
"--app-version .* `",
"--app-version \"" + version + "\" `"
);
replaceInFile(
Path.of("pom.xml"),
"<version>.*</version>",
"<version>" + version + "</version>"
);
replaceInFile(
Path.of("src", "main", "resources", "main-view.fxml"),
"text=\"Perfin .*\"",
"text=\"Perfin Version " + version + "\""
);
}
private static void replaceInFile(Path file, String pattern, String replacement) throws IOException {
System.out.println("Replacing " + pattern + " with " + replacement + " in " + file);
String fileContent = Files.readString(file);
Files.writeString(file, fileContent.replaceFirst(pattern, replacement));
}
}

View File

@ -24,7 +24,7 @@ module_path="$module_path:target/modules/h2-2.2.224.jar"
jpackage \
--name "Perfin" \
--app-version "1.0.0" \
--app-version "1.0.1" \
--description "Desktop application for personal finance. Add your accounts, track transactions, and store receipts, invoices, and more." \
--icon design/perfin-logo_256.png \
--vendor "Andrew Lalis" \

View File

@ -12,7 +12,7 @@ $modulePath = "$modulePath;target\modules\h2-2.2.224.jar"
jpackage `
--name "Perfin" `
--app-version "1.0.0" `
--app-version "1.0.1" `
--description "Desktop application for personal finance. Add your accounts, track transactions, and store receipts, invoices, and more." `
--icon design\perfin-logo_256.ico `
--vendor "Andrew Lalis" `

View File

@ -23,7 +23,7 @@
</top>
<bottom>
<HBox styleClass="std-padding,std-spacing">
<Label text="Perfin v0.0.1"/>
<Label text="Perfin Version 1.0.1"/>
</HBox>
</bottom>
</BorderPane>