From 8482824b360c5d29c0d85296b55dfb22322c7439 Mon Sep 17 00:00:00 2001 From: Fionera Date: Mon, 25 Nov 2024 21:48:56 +0100 Subject: [PATCH] fix(build): set arch in magefile --- .github/workflows/package.yaml | 2 +- magefile.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index 7a1d7dd..3616ef0 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -45,7 +45,7 @@ jobs: sudo apt update && sudo apt -y install make pkg-config rubygems && sudo gem install fpm - name: Build binary - run: VERSION=${PACKAGE_VERSION} GOARCH=${{ matrix.arch }} go run mage.go build + run: VERSION=${PACKAGE_VERSION} ARCH=${{ matrix.arch }} go run mage.go build - name: Build package run: | diff --git a/magefile.go b/magefile.go index 3636167..f8ecfb5 100644 --- a/magefile.go +++ b/magefile.go @@ -13,6 +13,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "github.com/magefile/mage/mg" "github.com/magefile/mage/sh" @@ -56,7 +57,12 @@ func Format() error { } func Build() error { - if err := sh.RunV("go", "build", "-o", "build/coraza-spoa"); err != nil { + arch := os.Getenv("ARCH") + if arch == "" { + arch = runtime.GOARCH + } + + if err := sh.RunWith(map[string]string{"GOARCH": arch}, "go", "build", "-o", "build/coraza-spoa"); err != nil { return err } return nil