automatically update version number

This commit is contained in:
duncathan 2024-12-17 19:25:32 -06:00
parent 0a93bf3867
commit 45586f9a95
4 changed files with 15 additions and 6 deletions

4
.gitignore vendored
View file

@ -19,3 +19,7 @@ cave_story_randomizer.egg-info/
*/__pycache__ */__pycache__
caver/version.py caver/version.py
pre_edited_cs/data/Stage/_version.txt
pre_edited_cs/freeware/window.rect

View file

@ -11,9 +11,6 @@ import platform as pl
import pre_edited_cs import pre_edited_cs
CSVERSION = 5
class CaverException(Exception): class CaverException(Exception):
pass pass
@ -67,8 +64,16 @@ def patch_files(patch_data: dict, output_dir: Path, platform: CSPlatform, progre
def ensure_base_files_exist(platform: CSPlatform, output_dir: Path): def ensure_base_files_exist(platform: CSPlatform, output_dir: Path):
internal_copy = pre_edited_cs.get_path() internal_copy = pre_edited_cs.get_path()
with internal_copy.joinpath("data", "Stage", "_version.txt").open() as version_file:
latest_version = version_file.readline()
version = output_dir.joinpath("data", "Stage", "_version.txt") version = output_dir.joinpath("data", "Stage", "_version.txt")
keep_existing_files = version.exists() and int(version.read_text()) >= CSVERSION current_version = "v0.0.0.0"
if version.exists():
with version.open() as version_file:
current_version = version_file.readline()
keep_existing_files = current_version >= latest_version
def should_ignore(path: str, names: list[str]): def should_ignore(path: str, names: list[str]):
base = ["__init__.py", "__pycache__", "ScriptSource", "__pyinstaller"] base = ["__init__.py", "__pycache__", "ScriptSource", "__pyinstaller"]

View file

@ -1 +0,0 @@
3

View file

@ -3,5 +3,6 @@ requires = ["setuptools>=44.0.0", "setuptools_scm[toml]>=3.4.3"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.setuptools_scm] [tool.setuptools_scm]
version_file_template = "v{version_tuple[0]}.{version_tuple[1]}.{version_tuple[2]}.{scm_version.distance}\n2019/03/07 - {scm_version.node_date.year:04}/{scm_version.node_date.month:02}/{scm_version.node_date.day:02}\nduncathan_salt"
local_scheme = "no-local-version" local_scheme = "no-local-version"
write_to = "caver/version.py" version_file = "pre_edited_cs/data/Stage/_version.txt"