Skip to content

Commit f94f07e

Browse files
authored
Merge pull request #409 from per1234/m1-build
Add macOS ARM 64-bit build target
2 parents aba2f26 + 4164141 commit f94f07e

File tree

6 files changed

+164
-56
lines changed

6 files changed

+164
-56
lines changed

Diff for: .github/workflows/publish-go-nightly-task.yml

+63-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
AWS_PLUGIN_TARGET: /arduino-lint/
1111
ARTIFACT_NAME: dist
1212

13-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
13+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
1414
on:
1515
schedule:
1616
# run every day at 1AM
@@ -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: |
101-
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
140+
# 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:

Diff for: .github/workflows/publish-go-tester-task.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
22
name: Publish Tester Build
33

4-
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
4+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
55
on:
66
create:
77
push:
@@ -39,9 +39,9 @@ jobs:
3939
run: |
4040
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
4141
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
42-
if [[ \
43-
"${{ github.event_name }}" != "create" || \
44-
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
42+
if [[
43+
"${{ github.event_name }}" != "create" ||
44+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
4545
]]; then
4646
# Run the other jobs.
4747
RESULT="true"
@@ -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"

Diff for: .github/workflows/release-go-task.yml

+63-17
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,23 @@ jobs:
5050
path: ${{ env.DIST_DIR }}
5151

5252
notarize-macos:
53+
name: Notarize ${{ matrix.artifact.name }}
5354
runs-on: macos-latest
5455
needs: create-release-artifacts
56+
outputs:
57+
checksum-darwin_amd64: ${{ steps.re-package.outputs.checksum-darwin_amd64 }}
58+
checksum-darwin_arm64: ${{ steps.re-package.outputs.checksum-darwin_arm64 }}
59+
60+
env:
61+
GON_CONFIG_PATH: gon.config.hcl
62+
63+
strategy:
64+
matrix:
65+
artifact:
66+
- name: darwin_amd64
67+
path: "macOS_64bit.tar.gz"
68+
- name: darwin_arm64
69+
path: "macOS_ARM64.tar.gz"
5570

5671
steps:
5772
- name: Checkout repository
@@ -91,38 +106,59 @@ jobs:
91106
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
92107
unzip gon_macos.zip -d /usr/local/bin
93108
109+
- name: Write gon config to file
110+
# gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
111+
run: |
112+
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
113+
# See: https://github.com/mitchellh/gon#configuration-file
114+
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
115+
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
116+
117+
sign {
118+
application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
119+
}
120+
121+
# Ask Gon for zip output to force notarization process to take place.
122+
# The CI will ignore the zip output, using the signed binary only.
123+
zip {
124+
output_path = "unused.zip"
125+
}
126+
EOF
127+
94128
- name: Sign and notarize binary
95129
env:
96130
AC_USERNAME: ${{ secrets.AC_USERNAME }}
97131
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
98132
run: |
99-
gon gon.config.hcl
133+
gon "${{ env.GON_CONFIG_PATH }}"
100134
101-
- name: Re-package binary and update checksum
135+
- name: Re-package binary and output checksum
136+
id: re-package
137+
working-directory: ${{ env.DIST_DIR }}
102138
# This step performs the following:
103139
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
104-
# 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
140+
# 2. Recalculate package checksum
141+
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
142+
# (it cannot be done there because of workflow job parallelization)
105143
run: |
106-
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
144+
# GitHub's upload/download-artifact actions don't preserve file permissions,
107145
# so we need to add execution permission back until the action is made to do this.
108-
chmod +x ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/${{ env.PROJECT_NAME }}
146+
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
109147
TAG="${GITHUB_REF/refs\/tags\//}"
110-
tar -czvf "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz" \
111-
-C ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/ ${{ env.PROJECT_NAME }} \
112-
-C ../../ LICENSE.txt
113-
CHECKSUM="$(shasum -a 256 ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz | cut -d " " -f 1)"
114-
perl \
115-
-pi \
116-
-w \
117-
-e "s/.*${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/${CHECKSUM} ${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/g;" \
118-
${{ env.DIST_DIR }}/*-checksums.txt
148+
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
149+
tar -czvf "$PACKAGE_FILENAME" \
150+
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
151+
-C ../../ LICENSE.txt
152+
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
153+
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
154+
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
119155
120156
- name: Upload artifacts
121157
uses: actions/upload-artifact@v3
122158
with:
123159
if-no-files-found: error
124160
name: ${{ env.ARTIFACT_NAME }}
125-
path: ${{ env.DIST_DIR }}
161+
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
126162

127163
create-release:
128164
runs-on: ubuntu-latest
@@ -135,13 +171,23 @@ jobs:
135171
name: ${{ env.ARTIFACT_NAME }}
136172
path: ${{ env.DIST_DIR }}
137173

174+
- name: Update checksum
175+
run: |
176+
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
177+
for checksum_line in "${checksum_lines[@]}"
178+
do
179+
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
180+
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
181+
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
182+
done
183+
138184
- name: Identify Prerelease
139185
# This is a workaround while waiting for create-release action
140186
# to implement auto pre-release based on tag
141187
id: prerelease
142188
run: |
143-
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
144-
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
189+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
190+
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
145191
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
146192
147193
- name: Create Github Release and upload artifacts

Diff for: DistTasks.yml

+24-1
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
@@ -210,7 +211,7 @@ tasks:
210211
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
211212
212213
vars:
213-
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
214+
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64"
214215
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
215216
BUILD_PLATFORM: "linux/arm64"
216217
CONTAINER_TAG: "{{.GO_VERSION}}-arm"
@@ -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"

Diff for: docs/installation.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,17 @@ your `PATH` environment variable.
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/arduino-lint/arduino-lint_latest_Linux_64bit.tar.gz
5253
[linux32]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Linux_32bit.tar.gz
5354
[linuxarm64]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Linux_ARM64.tar.gz
5455
[linuxarm32]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Linux_ARMv7.tar.gz
5556
[windows64]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Windows_64bit.zip
5657
[windows32]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Windows_32bit.zip
57-
[macos]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_macOS_64bit.tar.gz
58+
[macos64]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_macOS_64bit.tar.gz
59+
[macosarm64]: https://downloads.arduino.cc/arduino-lint/arduino-lint_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/arduino-lint/nightly/arduino-lint_nightly-latest_Linux_64bit.tar.gz
7679
[linux32-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Linux_32bit.tar.gz
7780
[linuxarm64-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Linux_ARM64.tar.gz
7881
[linuxarm32-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Linux_ARMv7.tar.gz
7982
[windows64-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Windows_64bit.zip
8083
[windows32-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Windows_32bit.zip
81-
[macos-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_macOS_64bit.tar.gz
84+
[macos64-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_macOS_64bit.tar.gz
85+
[macosarm64-nightly]: https://downloads.arduino.cc/arduino-lint/arduino-lint_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` )

Diff for: gon.config.hcl

-14
This file was deleted.

0 commit comments

Comments
 (0)