From ff949891d9505fe58988b9314ccdba4cddbe14bb Mon Sep 17 00:00:00 2001 From: nxrmqlly Date: Sun, 20 Oct 2024 23:44:30 +0530 Subject: [PATCH] fixed multi OS builds, optimised Workflow --- .github/workflows/wails-build.yml | 17 ++++++++++------- backend/utils/run_cmd_unix.go | 12 ++++++++++++ .../utils/{run_cmd.go => run_cmd_windows.go} | 3 +++ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 backend/utils/run_cmd_unix.go rename backend/utils/{run_cmd.go => run_cmd_windows.go} (85%) diff --git a/.github/workflows/wails-build.yml b/.github/workflows/wails-build.yml index fc6890e..02b7f19 100644 --- a/.github/workflows/wails-build.yml +++ b/.github/workflows/wails-build.yml @@ -13,17 +13,24 @@ jobs: runs-on: ubuntu-latest steps: - # Checkout the repository - name: Checkout code uses: actions/checkout@v3 - # Set up Go environment (required for Wails backend) - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.22' + + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - # Install required packages for Wails - name: Install Wails dependencies run: | sudo apt-get update @@ -31,15 +38,11 @@ jobs: libgtk-3-dev \ libwebkit2gtk-4.0-dev - # Install Wails CLI - name: Install Wails run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - - # Install Go dependencies (optional if using Go modules) - name: Install Go dependencies run: go mod tidy - # Build the Wails project (Wails handles frontend+backend) - name: Build Wails App run: wails build diff --git a/backend/utils/run_cmd_unix.go b/backend/utils/run_cmd_unix.go new file mode 100644 index 0000000..0cd7d69 --- /dev/null +++ b/backend/utils/run_cmd_unix.go @@ -0,0 +1,12 @@ +//go:build !windows +// +build !windows + +package utils + +import ( + "os/exec" +) + +func RunCmd(cmd *exec.Cmd) ([]byte, error) { + return cmd.CombinedOutput() +} diff --git a/backend/utils/run_cmd.go b/backend/utils/run_cmd_windows.go similarity index 85% rename from backend/utils/run_cmd.go rename to backend/utils/run_cmd_windows.go index ca01a34..433255a 100644 --- a/backend/utils/run_cmd.go +++ b/backend/utils/run_cmd_windows.go @@ -1,3 +1,6 @@ +//go:build windows +// +build windows + package utils import (