From 59a0a49a39e4f9fb699aa3219575eaf7aea092d2 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 12 Jun 2024 17:13:33 +0200 Subject: [PATCH] Create a single universal executable for macos --- .github/workflows/release.yml | 32 +++++++++++++++++--------------- Taskfile.yml | 10 ---------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 432b4402..05d30a67 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,8 +40,6 @@ jobs: ext: ".exe" - os: windows-2019 ext: ".exe" - - os: macos-12 - arch: arm64 defaults: run: @@ -115,25 +113,29 @@ jobs: MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac CGO_CFLAGS: -mmacosx-version-min=10.15 CGO_LDFLAGS: -mmacosx-version-min=10.15 - GOOS: "darwin" - GOARCH: "amd64" - run: task go:build - if: matrix.os == 'macos-12' && matrix.arch == 'amd64' + run: | + task go:build + mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_amd64 + if: matrix.os == 'macos-12' - - name: Build the Agent for macos arm64 - env: - CGO_ENABLED: 1 - MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac - CGO_CFLAGS: -mmacosx-version-min=10.15 - CGO_LDFLAGS: -mmacosx-version-min=10.15 - run: task go:build-macos-arm - if: matrix.os == 'macos-12' && matrix.arch == 'arm64' + - name: Create universal macos executable + shell: zsh + run: lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_amd64 + if: matrix.os == 'macos-12' # this will create `public/` dir with compressed full bin (/-.gz) and a json file - name: Create autoupdate files run: go-selfupdate ${{ env.PROJECT_NAME }}${{ matrix.ext }} ${TAG_VERSION} if: matrix.arch != '386' && steps.prerelease.outputs.IS_PRE != 'true' + # for now we do not distribute m1 build, this is a workaround for now + - name: Copy autoupdate file for darwin-arm64 (m1 arch) + working-directory: public/ + run: | + cp darwin-amd64.json darwin-arm64.json + cp ${TAG_VERSION}/darwin-amd64.gz ${TAG_VERSION}/darwin-arm64.gz + if: matrix.os == 'macos-12' && steps.prerelease.outputs.IS_PRE != 'true' + - name: Create autoupdate files for win32 run: go-selfupdate -platform windows-${{ matrix.arch }} ${{ env.PROJECT_NAME }}${{ matrix.ext }} ${TAG_VERSION} if: matrix.arch == '386' && matrix.os == 'windows-2019' && steps.prerelease.outputs.IS_PRE != 'true' @@ -181,7 +183,7 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: ${{ env.PROJECT_NAME }}-macos-12-${{ matrix.arch }} + name: ${{ env.PROJECT_NAME }}-macos-12-amd64 # if we want to support darwin-arm64 in the future for real this has to change. path: ${{ env.EXE_PATH }} - name: Remove placeholder file diff --git a/Taskfile.yml b/Taskfile.yml index 8c15e73a..603a2ce9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -32,16 +32,6 @@ tasks: cmds: - go build -v {{.ADDITIONAL_FLAGS}} -o {{.PROJECT_NAME}} {{.LDFLAGS}} {{.WIN_FLAGS}}' - go:build-macos-arm: - desc: Build the project for win, to build 32bit `export GOARCH=386` and for 64 bit `export GOARCH=amd64` before `task build-win` - env: - GOOS: "darwin" - GOARCH: "arm64" - cmds: - - task: go:build - vars: - PROJECT_NAME: arduino-create-agent_arm64 - go:build-cli: desc: Build the project without tray icon support cmds: