From 57ddab9032ff4fe207f8012df6dec1814d760d72 Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 1 Aug 2025 14:17:14 -0500 Subject: [PATCH] ci: add 'version' task to taskfile, use in build.yml --- .github/workflows/build.yml | 19 +++++-------------- Taskfile.yml | 13 +++++++++---- tasks/Taskfile_windows.yml | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a673940..1d3c92f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies - run: sudo apt-get install libgtk-3-dev libayatana-appindicator3-dev + run: sudo apt-get install -y libgtk-3-dev libayatana-appindicator3-dev - name: Build Linux Binary run: task build @@ -36,9 +36,8 @@ jobs: - name: Get Version id: get_version run: | - VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo 'unknown') - echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - echo "BINARY_NAME=HATray-linux-amd64-$VERSION" >> $GITHUB_OUTPUT + echo "VERSION=$(task version --silent)" >> $GITHUB_OUTPUT + echo "BINARY_NAME=HATray-linux-amd64-$(task version --silent)" >> $GITHUB_OUTPUT - name: Rename Linux Binary with Version run: mv bin/HATray ${{ steps.get_version.outputs.BINARY_NAME }} @@ -76,16 +75,8 @@ jobs: id: get_version_win shell: pwsh run: | - # Extract the version using git tags, fallback to 'unknown' if it fails - try { - $version = git describe --tags --abbrev=0 2>$null - if ([string]::IsNullOrWhiteSpace($version)) { $version = 'unknown' } - } catch { - $version = 'unknown' - } - - echo "VERSION=$($version.Trim())" >> $env:GITHUB_OUTPUT - echo "BINARY_NAME=HATray-windows-amd64-$($version.Trim())" >> $env:GITHUB_OUTPUT + echo "VERSION=$(task version --silent)" >> $env:GITHUB_OUTPUT + echo "BINARY_NAME=HATray-windows-amd64-$(task version --silent)" >> $env:GITHUB_OUTPUT - name: Rename Windows Binary with Version shell: pwsh diff --git a/Taskfile.yml b/Taskfile.yml index ff9e39b..4ff349c 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,8 +1,8 @@ -version: '3' +version: "3" vars: - APP_NAME: 'HATray' - VERSION: '0.0.1' + APP_NAME: "HATray" + VERSION: "0.0.1" includes: build: @@ -43,4 +43,9 @@ tasks: deps: [deps, fmt, vet, test, build] cmds: - echo "Development workflow complete" - - echo "Run 'task windows:run' to start the application" \ No newline at end of file + - echo "Run 'task windows:run' to start the application" + + version: + desc: "Show the version of the application" + cmds: + - git describe --tags --abbrev=0 2>/dev/null || echo "unknown" diff --git a/tasks/Taskfile_windows.yml b/tasks/Taskfile_windows.yml index 108398a..0836c21 100644 --- a/tasks/Taskfile_windows.yml +++ b/tasks/Taskfile_windows.yml @@ -3,7 +3,7 @@ version: "3" vars: BINARY_NAME: "{{.APP_NAME}}.exe" VERSION: - sh: powershell -Command "try { agit describe --tags --abbrev=0 } catch { 'unknown' }" + sh: powershell -Command "try { git describe --tags --abbrev=0 } catch { 'unknown' }" COMMIT: sh: git rev-parse --short HEAD