Skip to content

Commit 59a0a49

Browse files
Create a single universal executable for macos
1 parent 596bbbe commit 59a0a49

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

.github/workflows/release.yml

+17-15
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ jobs:
4040
ext: ".exe"
4141
- os: windows-2019
4242
ext: ".exe"
43-
- os: macos-12
44-
arch: arm64
4543

4644
defaults:
4745
run:
@@ -115,25 +113,29 @@ jobs:
115113
MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac
116114
CGO_CFLAGS: -mmacosx-version-min=10.15
117115
CGO_LDFLAGS: -mmacosx-version-min=10.15
118-
GOOS: "darwin"
119-
GOARCH: "amd64"
120-
run: task go:build
121-
if: matrix.os == 'macos-12' && matrix.arch == 'amd64'
116+
run: |
117+
task go:build
118+
mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_amd64
119+
if: matrix.os == 'macos-12'
122120

123-
- name: Build the Agent for macos arm64
124-
env:
125-
CGO_ENABLED: 1
126-
MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac
127-
CGO_CFLAGS: -mmacosx-version-min=10.15
128-
CGO_LDFLAGS: -mmacosx-version-min=10.15
129-
run: task go:build-macos-arm
130-
if: matrix.os == 'macos-12' && matrix.arch == 'arm64'
121+
- name: Create universal macos executable
122+
shell: zsh
123+
run: lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_amd64
124+
if: matrix.os == 'macos-12'
131125

132126
# this will create `public/` dir with compressed full bin (<version>/<os>-<arch>.gz) and a json file
133127
- name: Create autoupdate files
134128
run: go-selfupdate ${{ env.PROJECT_NAME }}${{ matrix.ext }} ${TAG_VERSION}
135129
if: matrix.arch != '386' && steps.prerelease.outputs.IS_PRE != 'true'
136130

131+
# for now we do not distribute m1 build, this is a workaround for now
132+
- name: Copy autoupdate file for darwin-arm64 (m1 arch)
133+
working-directory: public/
134+
run: |
135+
cp darwin-amd64.json darwin-arm64.json
136+
cp ${TAG_VERSION}/darwin-amd64.gz ${TAG_VERSION}/darwin-arm64.gz
137+
if: matrix.os == 'macos-12' && steps.prerelease.outputs.IS_PRE != 'true'
138+
137139
- name: Create autoupdate files for win32
138140
run: go-selfupdate -platform windows-${{ matrix.arch }} ${{ env.PROJECT_NAME }}${{ matrix.ext }} ${TAG_VERSION}
139141
if: matrix.arch == '386' && matrix.os == 'windows-2019' && steps.prerelease.outputs.IS_PRE != 'true'
@@ -181,7 +183,7 @@ jobs:
181183
- name: Download artifact
182184
uses: actions/download-artifact@v4
183185
with:
184-
name: ${{ env.PROJECT_NAME }}-macos-12-${{ matrix.arch }}
186+
name: ${{ env.PROJECT_NAME }}-macos-12-amd64 # if we want to support darwin-arm64 in the future for real this has to change.
185187
path: ${{ env.EXE_PATH }}
186188

187189
- name: Remove placeholder file

Taskfile.yml

-10
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ tasks:
3232
cmds:
3333
- go build -v {{.ADDITIONAL_FLAGS}} -o {{.PROJECT_NAME}} {{.LDFLAGS}} {{.WIN_FLAGS}}'
3434

35-
go:build-macos-arm:
36-
desc: Build the project for win, to build 32bit `export GOARCH=386` and for 64 bit `export GOARCH=amd64` before `task build-win`
37-
env:
38-
GOOS: "darwin"
39-
GOARCH: "arm64"
40-
cmds:
41-
- task: go:build
42-
vars:
43-
PROJECT_NAME: arduino-create-agent_arm64
44-
4535
go:build-cli:
4636
desc: Build the project without tray icon support
4737
cmds:

0 commit comments

Comments
 (0)