Skip to content

Commit 5d7cbfc

Browse files
Create a single universal executable for macos
1 parent 596bbbe commit 5d7cbfc

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

.github/workflows/release.yml

+17-8
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,10 +113,8 @@ 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: task go:build-macos
117+
if: matrix.os == 'macos-12'
122118

123119
- name: Build the Agent for macos arm64
124120
env:
@@ -127,13 +123,26 @@ jobs:
127123
CGO_CFLAGS: -mmacosx-version-min=10.15
128124
CGO_LDFLAGS: -mmacosx-version-min=10.15
129125
run: task go:build-macos-arm
130-
if: matrix.os == 'macos-12' && matrix.arch == 'arm64'
126+
if: matrix.os == 'macos-12'
127+
128+
- name: Create universal macos executable
129+
shell: zsh
130+
run: lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_amd64 ${{ env.PROJECT_NAME }}_arm64
131+
if: matrix.os == 'macos-12'
131132

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

138+
# for now we do not distribute m1 build, this is a workaround for now
139+
- name: Copy autoupdate file for darwin-arm64 (m1 arch)
140+
working-directory: public/
141+
run: |
142+
cp darwin-amd64.json darwin-arm64.json
143+
cp ${TAG_VERSION}/darwin-amd64.gz ${TAG_VERSION}/darwin-arm64.gz
144+
if: matrix.os == 'macos-12' && steps.prerelease.outputs.IS_PRE != 'true'
145+
137146
- name: Create autoupdate files for win32
138147
run: go-selfupdate -platform windows-${{ matrix.arch }} ${{ env.PROJECT_NAME }}${{ matrix.ext }} ${TAG_VERSION}
139148
if: matrix.arch == '386' && matrix.os == 'windows-2019' && steps.prerelease.outputs.IS_PRE != 'true'
@@ -181,7 +190,7 @@ jobs:
181190
- name: Download artifact
182191
uses: actions/download-artifact@v4
183192
with:
184-
name: ${{ env.PROJECT_NAME }}-macos-12-${{ matrix.arch }}
193+
name: ${{ env.PROJECT_NAME }}-macos-12-amd64 # if we want to support darwin-arm64 in the future for real this has to change.
185194
path: ${{ env.EXE_PATH }}
186195

187196
- name: Remove placeholder file

Taskfile.yml

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

35+
go:build-macos:
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: "amd64"
40+
cmds:
41+
- task: go:build
42+
vars:
43+
PROJECT_NAME: arduino-create-agent_amd64
44+
3545
go:build-macos-arm:
3646
desc: Build the project for win, to build 32bit `export GOARCH=386` and for 64 bit `export GOARCH=amd64` before `task build-win`
3747
env:

0 commit comments

Comments
 (0)