mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-19 13:18:24 +00:00
chore: change changelog updater to be standalone
This commit is contained in:
@@ -16,12 +16,18 @@
|
||||
*/
|
||||
package com.jpexs.build;
|
||||
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -39,9 +45,29 @@ public class ChangelogUpdater {
|
||||
private static final String PR_URL_PREFIX = GITHUB_ADDRESS + "pull/";
|
||||
|
||||
private static final String CHANGELOG_FILENAME = "CHANGELOG.md";
|
||||
|
||||
|
||||
|
||||
private static String readFile(String file) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
byte[] buf = new byte[4096];
|
||||
int cnt;
|
||||
while ((cnt = fis.read(buf)) > 0) {
|
||||
baos.write(buf, 0, cnt);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ChangelogUpdater.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
try {
|
||||
return new String(baos.toByteArray(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(ChangelogUpdater.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
String changeLog = Helper.readTextFile(CHANGELOG_FILENAME);
|
||||
String changeLog = readFile(CHANGELOG_FILENAME);
|
||||
changeLog = changeLog.replaceAll("\\[[^\\]]+\\]: [^\\r\\n]+\\r\\n", "");
|
||||
|
||||
changeLog = changeLog.replaceAll("\\[#([0-9]+)\\]", "#$1");
|
||||
@@ -107,6 +133,10 @@ public class ChangelogUpdater {
|
||||
changeLog += "[PR" + pr + "]: " + PR_URL_PREFIX + pr + "\r\n";
|
||||
}
|
||||
|
||||
Helper.writeFile(CHANGELOG_FILENAME, changeLog.getBytes("UTF-8"));
|
||||
try(FileOutputStream fos = new FileOutputStream(CHANGELOG_FILENAME)) {
|
||||
fos.write(changeLog.getBytes("UTF-8"));
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ChangelogUpdater.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user