diff --git a/.github/workflows/build-gui.yml b/.github/workflows/build-gui.yml index c22eff3e8..192e0519d 100644 --- a/.github/workflows/build-gui.yml +++ b/.github/workflows/build-gui.yml @@ -85,9 +85,10 @@ jobs: run: cargo clean - name: Build + shell: bash run: | pnpm i - pnpm run skipbundler + pnpm run skipbundler --config $( ./gui/scripts/gitversion.mjs ) - if: matrix.os == 'windows-latest' name: Upload a Build Artifact (Windows) diff --git a/.github/workflows/gradle.yaml b/.github/workflows/gradle.yaml index 7ff7fd8c6..2693d19c3 100644 --- a/.github/workflows/gradle.yaml +++ b/.github/workflows/gradle.yaml @@ -183,7 +183,7 @@ jobs: - name: Build run: | pnpm i - pnpm run tauri build + pnpm run tauri build --config $( ./gui/scripts/gitversion.mjs ) - name: Make GUI tarball run: | @@ -259,7 +259,7 @@ jobs: run: | rustup target add x86_64-apple-darwin pnpm i - pnpm run tauri build --target universal-apple-darwin + pnpm run tauri build --target universal-apple-darwin --config $( ./gui/scripts/gitversion.mjs ) - name: Modify Application run: | @@ -331,9 +331,10 @@ jobs: run: cargo clean - name: Build + shell: bash run: | pnpm i - pnpm run skipbundler + pnpm run skipbundler --config $( ./gui/scripts/gitversion.mjs ) - name: Bundle to zips shell: bash diff --git a/gui/scripts/gitversion.mjs b/gui/scripts/gitversion.mjs new file mode 100755 index 000000000..01fdbbaf3 --- /dev/null +++ b/gui/scripts/gitversion.mjs @@ -0,0 +1,21 @@ +#!/usr/bin/env node +import { promisify } from 'node:util'; +import { exec as execCallback } from 'node:child_process'; +const exec = promisify(execCallback); + +const [commitHash, versionTag, gitClean] = await Promise.all([ + exec('git rev-parse --verify --short HEAD').then((res) => + res.stdout.trim().substring(1) + ), + exec('git --no-pager tag --sort -taggerdate --points-at HEAD').then((res) => + res.stdout.split('\n')[0].trim() + ), + // If not empty then it's not clean + exec('git status --porcelain').then((res) => (res.stdout ? false : true)), +]); + +console.log( + JSON.stringify({ + version: `${versionTag || `0.0.0-${commitHash}`}${gitClean ? '' : '-dirty'}`, + }) +);