From 043f392e275b804c5ad09197d5cc5466157a7f50 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 12 Jun 2024 17:13:33 +0200 Subject: [PATCH 1/4] Create a single universal executable for macos --- .github/workflows/release.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f149c8eb..72b07c46 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -107,13 +107,33 @@ jobs: run: task go:build-win # GOARCH=amd64 by default on the runners if: matrix.os == 'windows-2019' && matrix.arch == 'amd64' - - name: Build the Agent for macos + - name: Build the Agent for macos amd64 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 + 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 + GOARCH: arm64 + run: | + task go:build + mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_arm64 + if: matrix.os == 'macos-12' + + - name: Create universal macos executable + run: | + lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_amd64 ${{ env.PROJECT_NAME }}_arm64 + rm ${{ env.PROJECT_NAME }}_amd64 ${{ env.PROJECT_NAME }}_arm64 if: matrix.os == 'macos-12' # this will create `public/` dir with compressed full bin (/-.gz) and a json file @@ -121,7 +141,6 @@ jobs: 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: | From 28152f8954358d9573ef3b81788639657eeeb6c4 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 12 Jun 2024 17:19:20 +0200 Subject: [PATCH 2/4] Update docs on macOS support --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5c97939b..a2efe270 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Get the [latest version](https://github.com/arduino/arduino-create-agent/release ## Apple silicon support The Arduino Agent is supported both on Intel and Apple silicon computers. This includes devices with the M1, M2 and M3 processors. -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. +The Arduino Agent is built both for Intel architectures and Apple silicon devices, but distributed as a single universal executable for macOS. ## Documentation @@ -50,7 +50,7 @@ The documentation has been moved to the [wiki](https://github.com/arduino/arduin ### Submitting an issue -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. +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. #### Security From 38e50a9811502a0bde1bc3f5c2216d9f489b5680 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Thu, 13 Jun 2024 09:51:22 +0200 Subject: [PATCH 3/4] Add macos-arm64 to the test builds --- .github/workflows/publish-go-tester-task.yml | 29 +++++++++++++++++--- Taskfile.yml | 3 +- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-go-tester-task.yml b/.github/workflows/publish-go-tester-task.yml index 66b38164..54d9c04f 100644 --- a/.github/workflows/publish-go-tester-task.yml +++ b/.github/workflows/publish-go-tester-task.yml @@ -30,6 +30,7 @@ on: repository_dispatch: env: + PROJECT_NAME: arduino-create-agent GO_VERSION: "1.21" jobs: @@ -119,18 +120,38 @@ jobs: run: task go:build-win # GOARCH=amd64 by default on the runners if: runner.os == 'Windows' && matrix.arch == '-amd64' - - name: Build the Agent for macos + - name: Build the Agent for macos amd 64 env: 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 + run: | + task go:build + mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME}}_amd64 + if: runner.os == 'macOS' + + - name: Build the Agent for macos amd 64 + env: + MACOSX_DEPLOYMENT_TARGET: 10.15 # minimum supported version for mac + CGO_CFLAGS: -mmacosx-version-min=10.15 + CGO_LDFLAGS: -mmacosx-version-min=10.15 + GOARCH: arm64 + CGO_ENABLED: 1 + run: | + task go:build + mv ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME}}_arm64 + if: runner.os == 'macOS' + + - name: Create universal macos executable + run: | + lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME}}_amd64 ${{ env.PROJECT_NAME}}_arm64 + rm ${{ env.PROJECT_NAME}}_amd64 ${{ env.PROJECT_NAME}}_arm64 if: runner.os == 'macOS' - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: arduino-create-agent-${{ matrix.os }}${{ matrix.arch }} + name: ${{ env.PROJECT_NAME}}-${{ matrix.os }}${{ matrix.arch }} path: | - arduino-create-agent* + ${{ env.PROJECT_NAME}}* if-no-files-found: error diff --git a/Taskfile.yml b/Taskfile.yml index 6b785276..603a2ce9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -84,7 +84,7 @@ tasks: cmds: - poetry run pytest tests - # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml poetry:install-deps: desc: Install dependencies managed by Poetry cmds: @@ -138,7 +138,6 @@ tasks: - task: go:vet - task: go:lint - vars: # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml PROJECT_NAME: arduino-create-agent From 78ed8cc34495c377372a63362a09229e2164333a Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Tue, 9 Jul 2024 09:29:18 +0200 Subject: [PATCH 4/4] Check that the new executable exists and is in the right path before proceding with the update --- updater/updater_darwin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updater/updater_darwin.go b/updater/updater_darwin.go index ec00f88c..105a529e 100644 --- a/updater/updater_darwin.go +++ b/updater/updater_darwin.go @@ -143,7 +143,7 @@ func checkForUpdates(currentVersion string, updateURL string, cmdName string) (s // Install new app logrus.WithField("from", tmpAppPath).WithField("to", currentAppPath).Info("Copying updated app") - if err := tmpAppPath.CopyDirTo(currentAppPath); err != nil { + if err := tmpAppPath.CopyDirTo(currentAppPath); err != nil || !paths.New(executablePath).Exist() { // Try rollback changes _ = currentAppPath.RemoveAll() _ = oldAppPath.Rename(currentAppPath)