diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f922bf4b..2d6ca014 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,7 @@ jobs: - name: Set build number run: | [IO.File]::WriteAllLines($pwd.path + "\resources\buildnumber", $env:GITHUB_RUN_NUMBER) + [IO.File]::WriteAllLines($pwd.path + "\resources\gitsha", $env:GITHUB_SHA) - name: Build app uses: ./.github/actions/build-app diff --git a/game/version.py b/game/version.py index 6bd9ca4c..b2e76b5d 100644 --- a/game/version.py +++ b/game/version.py @@ -6,15 +6,24 @@ MINOR_VERSION = 0 MICRO_VERSION = 0 +def _optional_build_id_component(path: Path) -> str | None: + if path.exists(): + return path.read_text().strip() + return None + + +BUILD_NUMBER = _optional_build_id_component(Path("resources/buildnumber")) +GIT_SHA = _optional_build_id_component(Path("resources/gitsha")) + + def _build_version_string() -> str: components = [ ".".join(str(v) for v in (MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)) ] - build_number_path = Path("resources/buildnumber") - if build_number_path.exists(): - with build_number_path.open("r", encoding="utf-8") as build_number_file: - components.append(build_number_file.readline()) - + if BUILD_NUMBER is not None: + components.append(BUILD_NUMBER) + if GIT_SHA is not None: + components.append(GIT_SHA) if not Path("resources/final").exists(): components.append("preview")