Skip to content

Commit 73e4ec4

Browse files
authored
Merge pull request #243 from arduino/m1-support
Add support for macos arm64 build
2 parents 25a3000 + 0e49ed3 commit 73e4ec4

File tree

15 files changed

+421
-127
lines changed

15 files changed

+421
-127
lines changed

other/installation-script/installation.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,17 @@ in your [`PATH`](https://wikipedia.org/wiki/PATH%5F%28variable%29) or add the TO
4646
| Linux | [32 bit][linux32] | [64 bit][linux64] |
4747
| Linux ARM | [32 bit][linuxarm32] | [64 bit][linuxarm64] |
4848
| Windows | [32 bit][windows32] | [64 bit][windows64] |
49-
| macOS | | [64 bit][macos] |
49+
| macOS | | [64 bit][macos64] |
50+
| macOS ARM | | [64 bit][macosarm64] |
5051

5152
[linux64]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Linux_64bit.tar.gz
5253
[linux32]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Linux_32bit.tar.gz
5354
[linuxarm64]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Linux_ARM64.tar.gz
5455
[linuxarm32]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Linux_ARMv7.tar.gz
5556
[windows64]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Windows_64bit.zip
5657
[windows32]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Windows_32bit.zip
57-
[macos]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_macOS_64bit.tar.gz
58+
[macos64]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_macOS_64bit.tar.gz
59+
[macosarm64]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_macOS_ARM64.tar.gz
5860

5961
### Previous versions
6062

@@ -70,15 +72,17 @@ get the latest nightly build available for the supported platform, use the follo
7072
| Linux | [32 bit][linux32-nightly] | [64 bit][linux64-nightly] |
7173
| Linux ARM | [32 bit][linuxarm32-nightly] | [64 bit][linuxarm64-nightly] |
7274
| Windows | [32 bit][windows32-nightly] | [64 bit][windows64-nightly] |
73-
| macOS | | [64 bit][macos-nightly] |
75+
| macOS | | [64 bit][macos64-nightly] |
76+
| macOS ARM | | [64 bit][macosarm64-nightly] |
7477

7578
[linux64-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Linux_64bit.tar.gz
7679
[linux32-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Linux_32bit.tar.gz
7780
[linuxarm64-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Linux_ARM64.tar.gz
7881
[linuxarm32-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Linux_ARMv7.tar.gz
7982
[windows64-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Windows_64bit.zip
8083
[windows32-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Windows_32bit.zip
81-
[macos-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_macOS_64bit.tar.gz
84+
[macos64-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_macOS_64bit.tar.gz
85+
[macosarm64-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_nightly-latest_macOS_ARM64.tar.gz
8286

8387
> These links return a `302: Found` response, redirecting to latest generated builds by replacing `latest` with the
8488
> latest available build date, using the format YYYYMMDD (i.e for 2019-08-06 `latest` is replaced with `20190806` )

workflow-templates/assets/general/gon.config.hcl

Lines changed: 0 additions & 14 deletions
This file was deleted.

workflow-templates/assets/release-go-crosscompile-task/DistTasks.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ tasks:
3232
- task: Linux_ARMv7
3333
- task: Linux_ARM64
3434
- task: macOS_64bit
35+
- task: macOS_ARM64
3536

3637
Windows_32bit:
3738
desc: Builds Windows 32 bit binaries
@@ -164,3 +165,19 @@ tasks:
164165
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_amd64"
165166
PACKAGE_PLATFORM: "macOS_64bit"
166167
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
168+
169+
macOS_ARM64:
170+
desc: Builds Mac OS X ARM64 binaries
171+
env:
172+
GOOS: "darwin"
173+
GOARCH: "arm64"
174+
cmds:
175+
- |
176+
go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}
177+
cd {{.DIST_DIR}}
178+
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
179+
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
180+
vars:
181+
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_arm64"
182+
PACKAGE_PLATFORM: "macOS_ARM64"
183+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

workflow-templates/assets/release-go-task/DistTasks.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ tasks:
3434
- task: Linux_ARMv7
3535
- task: Linux_ARM64
3636
- task: macOS_64bit
37+
- task: macOS_ARM64
3738

3839
Windows_32bit:
3940
desc: Builds Windows 32 bit binaries
@@ -251,3 +252,25 @@ tasks:
251252
CONTAINER_TAG: "{{.GO_VERSION}}-darwin-debian10"
252253
PACKAGE_PLATFORM: "macOS_64bit"
253254
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
255+
256+
macOS_ARM64:
257+
desc: Builds Mac OS X ARM64 binaries
258+
dir: "{{.DIST_DIR}}"
259+
cmds:
260+
- |
261+
docker run -v `pwd`/..:/home/build -w /home/build \
262+
-e CGO_ENABLED=1 \
263+
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
264+
--build-cmd "{{.BUILD_COMMAND}}" \
265+
-p "{{.BUILD_PLATFORM}}"
266+
267+
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
268+
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
269+
270+
vars:
271+
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_arm64"
272+
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
273+
BUILD_PLATFORM: "darwin/arm64"
274+
CONTAINER_TAG: "{{.GO_VERSION}}-darwin-arm64-debian10"
275+
PACKAGE_PLATFORM: "macOS_ARM64"
276+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

workflow-templates/dependabot/workflow-template-copies/.github/workflows/publish-go-nightly-task.yml

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,25 @@ jobs:
4545
path: ${{ env.DIST_DIR }}
4646

4747
notarize-macos:
48+
name: Notarize ${{ matrix.artifact.name }}
4849
runs-on: macos-latest
4950
needs: create-nightly-artifacts
5051

52+
outputs:
53+
checksum-darwin_amd64: ${{ steps.re-package.outputs.checksum-darwin_amd64 }}
54+
checksum-darwin_arm64: ${{ steps.re-package.outputs.checksum-darwin_arm64 }}
55+
56+
env:
57+
GON_CONFIG_PATH: gon.config.hcl
58+
59+
strategy:
60+
matrix:
61+
artifact:
62+
- name: darwin_amd64
63+
path: "macOS_64bit.tar.gz"
64+
- name: darwin_arm64
65+
path: "macOS_ARM64.tar.gz"
66+
5167
steps:
5268
- name: Checkout repository
5369
uses: actions/checkout@v3
@@ -86,38 +102,59 @@ jobs:
86102
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
87103
unzip gon_macos.zip -d /usr/local/bin
88104
105+
- name: Write gon config to file
106+
# gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
107+
run: |
108+
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
109+
# See: https://github.com/mitchellh/gon#configuration-file
110+
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
111+
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
112+
113+
sign {
114+
application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
115+
}
116+
117+
# Ask Gon for zip output to force notarization process to take place.
118+
# The CI will ignore the zip output, using the signed binary only.
119+
zip {
120+
output_path = "unused.zip"
121+
}
122+
EOF
123+
89124
- name: Sign and notarize binary
90125
env:
91126
AC_USERNAME: ${{ secrets.AC_USERNAME }}
92127
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
93128
run: |
94-
gon gon.config.hcl
129+
gon "${{ env.GON_CONFIG_PATH }}"
95130
96-
- name: Re-package binary and update checksum
131+
- name: Re-package binary and output checksum
132+
id: re-package
133+
working-directory: ${{ env.DIST_DIR }}
97134
# This step performs the following:
98135
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
99-
# 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
136+
# 2. Recalculate package checksum
137+
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
138+
# (it cannot be done there because of workflow job parallelization)
100139
run: |
101140
# GitHub's upload/download-artifact actions don't preserve file permissions,
102141
# so we need to add execution permission back until the action is made to do this.
103-
chmod +x "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/${{ env.PROJECT_NAME }}"
104-
PACKAGE_FILENAME="$(basename ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_nightly-*_macOS_64bit.tar.gz)"
105-
tar -czvf "${{ env.DIST_DIR }}/$PACKAGE_FILENAME" \
106-
-C "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/" "${{ env.PROJECT_NAME }}" \
142+
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
143+
# Use of an array here is required for globbing
144+
PACKAGE_FILENAME=(${{ env.PROJECT_NAME }}_nightly-*${{ matrix.artifact.path }})
145+
tar -czvf "$PACKAGE_FILENAME" \
146+
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
107147
-C ../../ LICENSE.txt
108-
CHECKSUM="$(shasum -a 256 ${{ env.DIST_DIR }}/$PACKAGE_FILENAME | cut -d " " -f 1)"
109-
perl \
110-
-pi \
111-
-w \
112-
-e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" \
113-
${{ env.DIST_DIR }}/*-checksums.txt
148+
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
149+
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
150+
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
114151
115152
- name: Upload artifacts
116153
uses: actions/upload-artifact@v3
117154
with:
118155
if-no-files-found: error
119156
name: ${{ env.ARTIFACT_NAME }}
120-
path: ${{ env.DIST_DIR }}
157+
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
121158

122159
publish-nightly:
123160
runs-on: ubuntu-latest
@@ -130,6 +167,16 @@ jobs:
130167
name: ${{ env.ARTIFACT_NAME }}
131168
path: ${{ env.DIST_DIR }}
132169

170+
- name: Update checksum
171+
run: |
172+
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
173+
for checksum_line in "${checksum_lines[@]}"
174+
do
175+
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
176+
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
177+
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
178+
done
179+
133180
- name: Upload release files on Arduino downloads servers
134181
uses: docker://plugins/s3
135182
env:

workflow-templates/dependabot/workflow-template-copies/.github/workflows/publish-go-tester-task.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ jobs:
106106
name: Linux_ARMv7
107107
- path: "*macOS_64bit.tar.gz"
108108
name: macOS_64
109+
- path: "*macOS_ARM64.tar.gz"
110+
name: macOS_ARM64
109111
- path: "*Windows_32bit.zip"
110112
name: Windows_X86-32
111113
- path: "*Windows_64bit.zip"

workflow-templates/dependabot/workflow-template-copies/.github/workflows/release-go-crosscompile-task.yml

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,23 @@ jobs:
5757
path: ${{ env.DIST_DIR }}
5858

5959
notarize-macos:
60+
name: Notarize ${{ matrix.artifact.name }}
6061
runs-on: macos-latest
6162
needs: create-release-artifacts
63+
outputs:
64+
checksum-darwin_amd64: ${{ steps.re-package.outputs.checksum-darwin_amd64 }}
65+
checksum-darwin_arm64: ${{ steps.re-package.outputs.checksum-darwin_arm64 }}
66+
67+
env:
68+
GON_CONFIG_PATH: gon.config.hcl
69+
70+
strategy:
71+
matrix:
72+
artifact:
73+
- name: darwin_amd64
74+
path: "macOS_64bit.tar.gz"
75+
- name: darwin_arm64
76+
path: "macOS_ARM64.tar.gz"
6277

6378
steps:
6479
- name: Checkout repository
@@ -98,38 +113,59 @@ jobs:
98113
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
99114
unzip gon_macos.zip -d /usr/local/bin
100115
116+
- name: Write gon config to file
117+
# gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
118+
run: |
119+
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
120+
# See: https://github.com/mitchellh/gon#configuration-file
121+
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
122+
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
123+
124+
sign {
125+
application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
126+
}
127+
128+
# Ask Gon for zip output to force notarization process to take place.
129+
# The CI will ignore the zip output, using the signed binary only.
130+
zip {
131+
output_path = "unused.zip"
132+
}
133+
EOF
134+
101135
- name: Sign and notarize binary
102136
env:
103137
AC_USERNAME: ${{ secrets.AC_USERNAME }}
104138
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
105139
run: |
106-
gon gon.config.hcl
140+
gon "${{ env.GON_CONFIG_PATH }}"
107141
108-
- name: Re-package binary and update checksum
142+
- name: Re-package binary and output checksum
143+
id: re-package
144+
working-directory: ${{ env.DIST_DIR }}
109145
# This step performs the following:
110146
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
111-
# 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
147+
# 2. Recalculate package checksum
148+
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
149+
# (it cannot be done there because of workflow job parallelization)
112150
run: |
113151
# GitHub's upload/download-artifact actions don't preserve file permissions,
114152
# so we need to add execution permission back until the action is made to do this.
115-
chmod +x ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/${{ env.PROJECT_NAME }}
153+
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
116154
TAG="${GITHUB_REF/refs\/tags\//}"
117-
tar -czvf "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz" \
118-
-C ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/ ${{ env.PROJECT_NAME }} \
119-
-C ../../ LICENSE.txt
120-
CHECKSUM="$(shasum -a 256 ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz | cut -d " " -f 1)"
121-
perl \
122-
-pi \
123-
-w \
124-
-e "s/.*${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/${CHECKSUM} ${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/g;" \
125-
${{ env.DIST_DIR }}/*-checksums.txt
155+
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
156+
tar -czvf "$PACKAGE_FILENAME" \
157+
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
158+
-C ../../ LICENSE.txt
159+
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
160+
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
161+
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
126162
127163
- name: Upload artifacts
128164
uses: actions/upload-artifact@v3
129165
with:
130166
if-no-files-found: error
131167
name: ${{ env.ARTIFACT_NAME }}
132-
path: ${{ env.DIST_DIR }}
168+
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
133169

134170
create-release:
135171
runs-on: ubuntu-latest
@@ -142,6 +178,16 @@ jobs:
142178
name: ${{ env.ARTIFACT_NAME }}
143179
path: ${{ env.DIST_DIR }}
144180

181+
- name: Update checksum
182+
run: |
183+
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
184+
for checksum_line in "${checksum_lines[@]}"
185+
do
186+
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
187+
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
188+
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
189+
done
190+
145191
- name: Identify Prerelease
146192
# This is a workaround while waiting for create-release action
147193
# to implement auto pre-release based on tag

0 commit comments

Comments
 (0)