From 240833c824bcea2431e25f89ade7e741a5a8a3dd Mon Sep 17 00:00:00 2001 From: Kariaro <25615845+Kariaro@users.noreply.github.com> Date: Tue, 8 Jun 2021 22:20:49 +0200 Subject: [PATCH] feat: Added auto-bumper plugin --- .autobumper.js | 99 +++++++++++++++++++ .autorc | 1 + .github/workflows/build.yml | 1 + .../multichat/bungee/MultiChat.java | 3 +- 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 .autobumper.js diff --git a/.autobumper.js b/.autobumper.js new file mode 100644 index 00000000..514f3e1e --- /dev/null +++ b/.autobumper.js @@ -0,0 +1,99 @@ +const update_yml_version = (contents, previousVersion, releaseVersion) => { + return contents.replace( + /\nversion\:[\s]+[0-9]+(\.[0-9]+)+/g, + `\nversion: ${releaseVersion}` + ); +}; + +const update_plugin_annotation = (contents, previousVersion, releaseVersion) => { + return contents.replace( + /version[\s]+=[\s]+"[0-9]+(\.[0-9]+)+"/g, + `version = "${releaseVersion}"` + ); +}; + +const update_yml_quote_version = (contents, previousVersion, releaseVersion) => { + return contents.replace( + /\nversion\:[\s]+"[0-9]+(\.[0-9]+)+"/g, + `\nversion: "${releaseVersion}"` + ); +}; + +const append_version = (contents, previousVersion, releaseVersion) => { + return contents.replace( + /ALLOWED_VERSIONS = new String\[\] {[\s]+/g, + `ALLOWED_VERSIONS = new String[] {\n\t\t\t"${releaseVersion}",\n\t\t\t` + ); +}; + +const append_version_latest = (contents, previousVersion, releaseVersion) => { + return contents.replace( + /LATEST_VERSION = "[0-9]+(\.[0-9]+)+";/g, + `LATEST_VERSION = "${releaseVersion}";` + ); +}; + +module.exports = { + bumpFiles: [ + { + path: 'src/main/java/xyz/olivermartin/multichat/local/sponge/MultiChatLocalSpongePlugin.java', + task: update_plugin_annotation + }, + { + path: 'src/main/java/xyz/olivermartin/multichat/bungee/MultiChat.java', + task: append_version + }, + { + path: 'src/main/java/xyz/olivermartin/multichat/bungee/MultiChat.java', + task: append_version_latest + }, + { + path: 'src/main/resources/bungee.yml', + task: update_yml_version + }, + { + path: 'src/main/resources/plugin.yml', + task: update_yml_version + }, + { + path: 'src/main/resources/chatcontrol_fr.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/chatcontrol.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/config_fr.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/config.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/joinmessages_fr.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/joinmessages.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/localconfig_fr.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/localconfig.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/messages_fr.yml', + task: update_yml_quote_version + }, + { + path: 'src/main/resources/messages.yml', + task: update_yml_quote_version + } + ] +}; diff --git a/.autorc b/.autorc index 13c3f866..e47e75c1 100644 --- a/.autorc +++ b/.autorc @@ -4,6 +4,7 @@ "conventional-commits", "first-time-contributor", "released", + ["auto-plugin-auto-bumper", {"scripted":true}], ["maven", {"mavenReleaseGoals": ["package"]}], ["upload-assets", ["./target/multichat*.jar"]] ], diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1208ee98..edff7470 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,7 @@ jobs: run: | git fetch --unshallow --tags yarn add -D auto + yarn add -D auto-plugin-auto-bumper yarn add -D @auto-it/maven yarn add -D @auto-it/all-contributors yarn add -D @auto-it/conventional-commits diff --git a/src/main/java/xyz/olivermartin/multichat/bungee/MultiChat.java b/src/main/java/xyz/olivermartin/multichat/bungee/MultiChat.java index 97380d1d..93c2289c 100644 --- a/src/main/java/xyz/olivermartin/multichat/bungee/MultiChat.java +++ b/src/main/java/xyz/olivermartin/multichat/bungee/MultiChat.java @@ -40,8 +40,7 @@ public class MultiChat extends Plugin implements Listener { public static final String LATEST_VERSION = "1.9.6"; public static final String[] ALLOWED_VERSIONS = new String[] { - - LATEST_VERSION, + "1.9.6", "1.9.5", "1.9.4", "1.9.3",