diff --git a/.github/scripts/release.py b/.github/scripts/release.py
new file mode 100644
index 00000000..8d4617ad
--- /dev/null
+++ b/.github/scripts/release.py
@@ -0,0 +1,134 @@
+import os
+import re
+import shutil
+import subprocess
+import sys
+
+SCRIPT_PATH = os.path.realpath(__file__)
+SOURCE_MOD_DIRECTORY = os.path.dirname(SCRIPT_PATH)
+
+if "GITHUB_WORKSPACE" in os.environ:
+ SOURCE_MOD_DIRECTORY = os.environ["GITHUB_WORKSPACE"]
+
+LUA_FILE_PATH = os.path.join(SOURCE_MOD_DIRECTORY, "main.lua")
+METADATA_XML_PATH = os.path.join(SOURCE_MOD_DIRECTORY, "metadata.xml")
+LUA_VERSIONING_LINE = "EID.ModVersion ="
+LUA_COMMIT_LINE = "EID.ModVersionCommit ="
+
+
+def main():
+ #get_changes()
+ if not is_git_clean():
+ printf(
+ "Error: The current working directory must be clean before releasing a new version. Please push your changes to Git."
+ )
+ sys.exit(1)
+
+ # Validate that we can push and pull to the repository and that all commits are remotely synced.
+ current_branch_name = get_current_branch_name()
+ last_commit_hash = get_last_commit_hash()
+
+ subprocess.run(["git", "branch", f"--set-upstream-to=origin/{current_branch_name}", current_branch_name])
+ subprocess.run(["git", "pull", "--rebase"])
+ subprocess.run(["git", "push", "--set-upstream","origin", current_branch_name])
+
+ new_version = increment_lua_version(last_commit_hash)
+ set_metadata_xml_version(new_version)
+
+ subprocess.run(["git", "add", "--all"])
+ subprocess.run(["git", "commit", "--message", f"chore: release {new_version}"])
+ subprocess.run(["git", "push", "--set-upstream", "origin", current_branch_name])
+
+ printf(f"Released version: {new_version}")
+
+def get_changes():
+ stdout_bytes = subprocess.check_output(["git", "log", "--no-merges","--pretty=format:\"- %s (%h)\""])
+ stdout = stdout_bytes.decode("utf-8")
+ commits = stdout.split('\n')
+
+def is_git_clean():
+ stdout_bytes = subprocess.check_output(["git", "status", "--short"])
+ stdout = stdout_bytes.decode("utf-8")
+ trimmed_stdout = stdout.strip()
+ return len(trimmed_stdout) == 0
+
+def get_last_commit_hash():
+ stdout_bytes = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
+ stdout = stdout_bytes.decode("utf-8")
+ trimmed_stdout = stdout.strip()
+ return trimmed_stdout
+
+def get_current_branch_name():
+ stdout_bytes = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
+ stdout = stdout_bytes.decode("utf-8")
+ trimmed_stdout = stdout.strip()
+ return trimmed_stdout
+
+def increment_lua_version(last_commit_hash):
+ if not os.path.exists(LUA_FILE_PATH):
+ error(f"Failed to find the Lua file at: {LUA_FILE_PATH}")
+
+ with open(LUA_FILE_PATH) as f:
+ text = f.read()
+
+ match = re.search(r""+LUA_VERSIONING_LINE+r" (.*)", text)
+ if not match:
+ error(f"Failed to find the version in the Lua file at: {LUA_FILE_PATH}")
+
+ version_string = match.group(1)
+ version_mayor = int(version_string.split('.')[0])
+ version_minor = int(version_string.split('.')[1])
+
+ version_minor = version_minor + 1
+
+ new_version = f"{version_mayor}.{version_minor}"
+
+ text = re.sub(
+ f"{LUA_VERSIONING_LINE} {version_string}",
+ f"{LUA_VERSIONING_LINE} {new_version}",
+ text,
+ )
+
+ commit_match = re.search(r""+LUA_COMMIT_LINE+r" (.*)", text)
+ if commit_match:
+ match_string = commit_match.group(1)
+ text = re.sub(
+ f"{LUA_COMMIT_LINE} {match_string}",
+ f"{LUA_COMMIT_LINE} \"{last_commit_hash}\"",
+ text,
+ )
+
+ with open(LUA_FILE_PATH, "w", newline="\n") as f:
+ f.write(text)
+
+ return new_version
+
+
+def set_metadata_xml_version(new_version: str):
+ if not os.path.exists(METADATA_XML_PATH):
+ error(f'Failed to find the "metadata.xml" file at: {METADATA_XML_PATH}')
+
+ with open(METADATA_XML_PATH) as f:
+ text = f.read()
+
+ text = re.sub(
+ r"(.+?)",
+ f"{new_version}",
+ text,
+ )
+
+ with open(METADATA_XML_PATH, "w", newline="\n") as f:
+ f.write(text)
+
+
+def error(msg: str):
+ printf(f"Error: {msg}")
+ sys.exit(1)
+
+
+def printf(*args):
+ print(*args, flush=True)
+
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 00000000..ab16f722
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,40 @@
+name: Release
+
+on:
+ workflow_dispatch
+
+jobs:
+ release:
+ name: Increase mod version
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout the repository
+ uses: actions/checkout@v3
+
+ - uses: actions/setup-python@v4.5.0
+ with:
+ python-version: '3.10'
+
+ - name: git
+ run: |
+ # setup the username and email.
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
+ git config --local user.name "github-actions[bot]"
+ - run: python .github/scripts/release.py
+ push_to_steam:
+ name: Upload mod to steam workshop
+ runs-on: ubuntu-latest
+ needs: [release]
+ steps:
+ - name: Checkout the repository
+ uses: actions/checkout@v3
+
+ # Your other CI tasks would go here, if you have any. (e.g. building artifacts, linting)
+
+ - name: Upload the mod to Steam Workshop
+ uses: IsaacScript/isaac-steam-workshop-upload@v2
+ with:
+ mod_path: .
+ change_note: "Changes for this mod are [url=https://github.com/wofsauge/External-Item-Descriptions/releases]tracked on GitHub[/url]."
+ env:
+ CONFIG_VDF_CONTENTS: ${{ secrets.CONFIG_VDF_CONTENTS }}
diff --git a/eid_mcm.lua b/eid_mcm.lua
index 2f32ece9..1e593422 100644
--- a/eid_mcm.lua
+++ b/eid_mcm.lua
@@ -275,7 +275,7 @@ if MCMLoaded then
MCM.AddSpace("EID", "Info")
MCM.AddText("EID", "Info", function() return "External Item Descriptions" end)
MCM.AddSpace("EID", "Info")
- MCM.AddText("EID", "Info", function() return "Version "..EID.ModVersion .." ("..EID.GameVersion..")" end)
+ MCM.AddText("EID", "Info", function() return "Version "..EID.ModVersion .."_"..EID.ModVersionCommit.." ("..EID.GameVersion..")" end)
MCM.AddSpace("EID", "Info")
MCM.AddText("EID", "Info", function() return "by Wofsauge" end)
MCM.AddSpace("EID", "Info")
diff --git a/main.lua b/main.lua
index 90890a70..8c08087f 100644
--- a/main.lua
+++ b/main.lua
@@ -10,6 +10,7 @@ require("eid_config")
EID.Config = EID.UserConfig
EID.Config.Version = "3.2" -- note: changing this will reset everyone's settings to default!
EID.ModVersion = "4.52"
+EID.ModVersionCommit = "4a8cdc8"
EID.DefaultConfig.Version = EID.Config.Version
EID.isHidden = false
EID.player = nil -- The primary Player Entity of Player 1