Skip to content

Commit

Permalink
Create a single universal executable for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPologruto committed Jun 12, 2024
1 parent 596bbbe commit 59a0a49
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ jobs:
ext: ".exe"
- os: windows-2019
ext: ".exe"
- os: macos-12
arch: arm64

defaults:
run:
Expand Down Expand Up @@ -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 (<version>/<os>-<arch>.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'
Expand Down Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 59a0a49

Please sign in to comment.