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 committed by Raffson
parent 9ad92d26d4
commit 2ac9d6bd98
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 15 additions and 5 deletions

View File

@ -25,6 +25,7 @@ jobs:
- name: Set build number - name: Set build number
run: | run: |
[IO.File]::WriteAllLines($pwd.path + "\resources\buildnumber", $env:GITHUB_RUN_NUMBER) [IO.File]::WriteAllLines($pwd.path + "\resources\buildnumber", $env:GITHUB_RUN_NUMBER)
[IO.File]::WriteAllLines($pwd.path + "\resources\gitsha", $env:GITHUB_SHA)
- name: Build app - name: Build app
uses: ./.github/actions/build-app uses: ./.github/actions/build-app

View File

@ -6,15 +6,24 @@ MINOR_VERSION = 0
MICRO_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: def _build_version_string() -> str:
components = [ components = [
".".join(str(v) for v in (MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)) ".".join(str(v) for v in (MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION))
] ]
build_number_path = Path("resources/buildnumber") if BUILD_NUMBER is not None:
if build_number_path.exists(): components.append(BUILD_NUMBER)
with build_number_path.open("r", encoding="utf-8") as build_number_file: if GIT_SHA is not None:
components.append(build_number_file.readline()) components.append(GIT_SHA)
if not Path("resources/final").exists(): if not Path("resources/final").exists():
components.append("preview") components.append("preview")