Add the git SHA to the build ID.

The build number is actually a pain to use. The git SHA is much more
useful.
This commit is contained in:
Dan Albert 2022-10-15 12:28:38 -07:00
parent b50219ba0b
commit 575cbf659c
2 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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")