Skip to content

Create a single universal executable for macOS #964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions .github/workflows/publish-go-tester-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ on:
repository_dispatch:

env:
PROJECT_NAME: arduino-create-agent
GO_VERSION: "1.21"

jobs:
Expand Down Expand Up @@ -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
25 changes: 22 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,40 @@ 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 (<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: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
3 changes: 1 addition & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion updater/updater_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading