Skip to content

Commit da1fa2e

Browse files
Create a single universal executable for macOS (#964)
* Create a single universal executable for macos * Update docs on macOS support * Add macos-arm64 to the test builds * Check that the new executable exists and is in the right path before proceding with the update
1 parent 04414e2 commit da1fa2e

File tree

5 files changed

+51
-12
lines changed

5 files changed

+51
-12
lines changed

.github/workflows/publish-go-tester-task.yml

+25-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ on:
3030
repository_dispatch:
3131

3232
env:
33+
PROJECT_NAME: arduino-create-agent
3334
GO_VERSION: "1.21"
3435

3536
jobs:
@@ -119,18 +120,38 @@ jobs:
119120
run: task go:build-win # GOARCH=amd64 by default on the runners
120121
if: runner.os == 'Windows' && matrix.arch == '-amd64'
121122

122-
- name: Build the Agent for macos
123+
- name: Build the Agent for macos amd 64
123124
env:
124125
MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac
125126
CGO_CFLAGS: -mmacosx-version-min=10.15
126127
CGO_LDFLAGS: -mmacosx-version-min=10.15
127-
run: task go:build
128+
run: |
129+
task go:build
130+
mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME}}_amd64
131+
if: runner.os == 'macOS'
132+
133+
- name: Build the Agent for macos amd 64
134+
env:
135+
MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac
136+
CGO_CFLAGS: -mmacosx-version-min=10.15
137+
CGO_LDFLAGS: -mmacosx-version-min=10.15
138+
GOARCH: arm64
139+
CGO_ENABLED: 1
140+
run: |
141+
task go:build
142+
mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME}}_arm64
143+
if: runner.os == 'macOS'
144+
145+
- name: Create universal macos executable
146+
run: |
147+
lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME}}_amd64 ${{ env.PROJECT_NAME}}_arm64
148+
rm ${{ env.PROJECT_NAME}}_amd64 ${{ env.PROJECT_NAME}}_arm64
128149
if: runner.os == 'macOS'
129150

130151
- name: Upload artifacts
131152
uses: actions/upload-artifact@v4
132153
with:
133-
name: arduino-create-agent-${{ matrix.os }}${{ matrix.arch }}
154+
name: ${{ env.PROJECT_NAME}}-${{ matrix.os }}${{ matrix.arch }}
134155
path: |
135-
arduino-create-agent*
156+
${{ env.PROJECT_NAME}}*
136157
if-no-files-found: error

.github/workflows/release.yml

+22-3
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,40 @@ jobs:
107107
run: task go:build-win # GOARCH=amd64 by default on the runners
108108
if: matrix.os == 'windows-2019' && matrix.arch == 'amd64'
109109

110-
- name: Build the Agent for macos
110+
- name: Build the Agent for macos amd64
111111
env:
112112
CGO_ENABLED: 1
113113
MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac
114114
CGO_CFLAGS: -mmacosx-version-min=10.15
115115
CGO_LDFLAGS: -mmacosx-version-min=10.15
116-
run: task go:build
116+
run: |
117+
task go:build
118+
mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_amd64
119+
if: matrix.os == 'macos-12'
120+
121+
- name: Build the Agent for macos arm64
122+
env:
123+
CGO_ENABLED: 1
124+
MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac
125+
CGO_CFLAGS: -mmacosx-version-min=10.15
126+
CGO_LDFLAGS: -mmacosx-version-min=10.15
127+
GOARCH: arm64
128+
run: |
129+
task go:build
130+
mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_arm64
131+
if: matrix.os == 'macos-12'
132+
133+
- name: Create universal macos executable
134+
run: |
135+
lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_amd64 ${{ env.PROJECT_NAME }}_arm64
136+
rm ${{ env.PROJECT_NAME }}_amd64 ${{ env.PROJECT_NAME }}_arm64
117137
if: matrix.os == 'macos-12'
118138

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

124-
# for now we do not distribute m1 build, this is a workaround for now
125144
- name: Copy autoupdate file for darwin-arm64 (m1 arch)
126145
working-directory: public/
127146
run: |

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Get the [latest version](https://github.com/arduino/arduino-create-agent/release
3232
## Apple silicon support
3333

3434
The Arduino Agent is supported both on Intel and Apple silicon computers. This includes devices with the M1, M2 and M3 processors.
35-
At the moment the Arduino Agent is only built for Intel architectures, but Apple silicon devices can run it thanks to the [Rosetta 2](https://support.apple.com/en-us/HT211861) translation layer by Apple.
35+
The Arduino Agent is built both for Intel architectures and Apple silicon devices, but distributed as a single universal executable for macOS.
3636

3737
## Documentation
3838

@@ -50,7 +50,7 @@ The documentation has been moved to the [wiki](https://github.com/arduino/arduin
5050

5151
### Submitting an issue
5252

53-
When submitting a new issue please search for duplicates before creating a new one. Help us by providing useful context and information. Please attach the output of the commands running at the debug console or attach [crash reports](https://github.com/arduino/arduino-create-agent/wiki/How-to-use-crashreport-functionality) if useful.
53+
When submitting a new issue please search for duplicates before creating a new one. Help us by providing useful context and information. Please attach the output of the commands running at the debug console or attach [crash reports](https://github.com/arduino/arduino-create-agent/wiki/How-to-use-crashreport-functionality) if useful.
5454

5555
#### Security
5656

Taskfile.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ tasks:
8484
cmds:
8585
- poetry run pytest tests
8686

87-
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
87+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
8888
poetry:install-deps:
8989
desc: Install dependencies managed by Poetry
9090
cmds:
@@ -138,7 +138,6 @@ tasks:
138138
- task: go:vet
139139
- task: go:lint
140140

141-
142141
vars:
143142
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml
144143
PROJECT_NAME: arduino-create-agent

updater/updater_darwin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func checkForUpdates(currentVersion string, updateURL string, cmdName string) (s
143143

144144
// Install new app
145145
logrus.WithField("from", tmpAppPath).WithField("to", currentAppPath).Info("Copying updated app")
146-
if err := tmpAppPath.CopyDirTo(currentAppPath); err != nil {
146+
if err := tmpAppPath.CopyDirTo(currentAppPath); err != nil || !paths.New(executablePath).Exist() {
147147
// Try rollback changes
148148
_ = currentAppPath.RemoveAll()
149149
_ = oldAppPath.Rename(currentAppPath)

0 commit comments

Comments
 (0)