From 756a319783db1b055251b1a606feeea258965b6a Mon Sep 17 00:00:00 2001
From: Umberto Baldi <u.baldi@arduino.cc>
Date: Thu, 30 Jun 2022 16:13:43 +0200
Subject: [PATCH 1/8] various fixes on the package index generation

---
 DistTasks.yml                      | 12 ++++++------
 extras/package_index.json.template | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/DistTasks.yml b/DistTasks.yml
index 1e24a834..3fdd8eb5 100644
--- a/DistTasks.yml
+++ b/DistTasks.yml
@@ -126,10 +126,10 @@ tasks:
       LINUX64_SHA:
         sh: sha256sum {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_64bit.tar.gz | cut -f1 -d " "
       LINUXARM_SHA:
-        sh: sha256sum {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_ARM.tar.gz | cut -f1 -d " "
+        sh: sha256sum {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_ARMv6.tar.gz | cut -f1 -d " "
       LINUXARM64_SHA:
         sh: sha256sum {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_ARM64.tar.gz | cut -f1 -d " "
-      OSX_SHA:
+      OSX64_SHA:
         sh: sha256sum {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_macOS_64bit.tar.gz | cut -f1 -d " "
       WINDOWS32_SIZE:
         sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Windows_32bit.zip | cut -f5 -d " "
@@ -140,10 +140,10 @@ tasks:
       LINUX64_SIZE:
         sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_64bit.tar.gz | cut -f5 -d " "
       LINUXARM_SIZE:
-        sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_ARM.tar.gz | cut -f5 -d " "
+        sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_ARMv6.tar.gz | cut -f5 -d " "
       LINUXARM64_SIZE:
         sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_ARM64.tar.gz | cut -f5 -d " "
-      OSX_SIZE:
+      OSX64_SIZE:
         sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_macOS_64bit.tar.gz | cut -f5 -d " "
     cmds:
       - |
@@ -158,8 +158,8 @@ tasks:
         sed "s/%%LINUXARM_SIZE%%/{{ .LINUXARM_SIZE }}/" |
         sed "s/%%LINUXARM64_SHA%%/{{ .LINUXARM64_SHA }}/" |
         sed "s/%%LINUXARM64_SIZE%%/{{ .LINUXARM64_SIZE }}/" |
-        sed "s/%%OSX_SHA%%/{{ .OSX_SHA }}/" |
-        sed "s/%%OSX_SIZE%%/{{ .OSX_SIZE }}/" |
+        sed "s/%%OSX64_SHA%%/{{ .OSX64_SHA }}/" |
+        sed "s/%%OSX64_SIZE%%/{{ .OSX64_SIZE }}/" |
         sed "s/%%WINDOWS32_SHA%%/{{ .WINDOWS32_SHA }}/" |
         sed "s/%%WINDOWS32_SIZE%%/{{ .WINDOWS32_SIZE }}/" |
         sed "s/%%WINDOWS64_SHA%%/{{ .WINDOWS64_SHA }}/" |
diff --git a/extras/package_index.json.template b/extras/package_index.json.template
index af20b928..f9b81443 100644
--- a/extras/package_index.json.template
+++ b/extras/package_index.json.template
@@ -10,7 +10,7 @@
               "size": "%%LINUX32_SIZE%%"
             },
             {
-              "host": "x86_64-pc-linux-gnu",
+              "host": "x86_64-linux-gnu",
               "url": "http://downloads.arduino.cc/arduino-fwuploader/%%FILENAME%%_%%VERSION%%_Linux_64bit.tar.gz",
               "archiveFileName": "%%FILENAME%%_%%VERSION%%_Linux_64bit.tar.gz",
               "checksum": "SHA-256:%%LINUX64_SHA%%",
@@ -31,16 +31,16 @@
               "size": "%%WINDOWS64_SIZE%%"
             },
             {
-              "host": "i386-apple-darwin11",
+              "host": "x86_64-apple-darwin",
               "url": "http://downloads.arduino.cc/arduino-fwuploader/%%FILENAME%%_%%VERSION%%_macOS_64bit.tar.gz",
               "archiveFileName": "%%FILENAME%%_%%VERSION%%_macOS_64bit.tar.gz",
-              "checksum": "SHA-256:%%OSX_SHA%%",
-              "size": "%%OSX_SIZE%%"
+              "checksum": "SHA-256:%%OSX64_SHA%%",
+              "size": "%%OSX64_SIZE%%"
             },
             {
               "host": "arm-linux-gnueabihf",
-              "url": "http://downloads.arduino.cc/arduino-fwuploader/%%FILENAME%%_%%VERSION%%_Linux_ARM.tar.gz",
-              "archiveFileName": "%%FILENAME%%_%%VERSION%%_Linux_ARM.tar.gz",
+              "url": "http://downloads.arduino.cc/arduino-fwuploader/%%FILENAME%%_%%VERSION%%_Linux_ARMv6.tar.gz",
+              "archiveFileName": "%%FILENAME%%_%%VERSION%%_Linux_ARMv6.tar.gz",
               "checksum": "SHA-256:%%LINUXARM_SHA%%",
               "size": "%%LINUXARM_SIZE%%"
             },

From 31fb8a299bfab0a6b76c684e5f92754f3ba4c5b4 Mon Sep 17 00:00:00 2001
From: Umberto Baldi <u.baldi@arduino.cc>
Date: Thu, 30 Jun 2022 16:53:26 +0200
Subject: [PATCH 2/8] uniform `DistTask.yml` to the assets repository: - add
 macos arm64 - differentiate linux arm into linux armv6, and linux armv7

---
 DistTasks.yml | 136 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 102 insertions(+), 34 deletions(-)

diff --git a/DistTasks.yml b/DistTasks.yml
index 3fdd8eb5..47b2242b 100644
--- a/DistTasks.yml
+++ b/DistTasks.yml
@@ -1,5 +1,25 @@
+# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-crosscompile-task/DistTasks.yml
 version: "3"
 
+# This taskfile is ideally meant to be project agnostic and could be dropped in
+# on other Go projects with minimal or no changes.
+#
+# To use it simply add the following lines to your main taskfile:
+#   includes:
+#     dist: ./DistTasks.yml
+#
+# The following variables must be declared in the including taskfile for the
+# build process to work correctly:
+# * DIST_DIR: the folder that will contain the final binaries and packages
+# * PROJECT_NAME: the name of the project, used in package name
+# * VERSION: the version of the project, used in package name and checksum file
+# * LD_FLAGS: flags used at build time
+#
+# The project MUST contain a LICENSE.txt file in the root folder or packaging will fail.
+
+vars:
+  CHECKSUM_FILE: "{{.VERSION}}-checksums.txt"
+
 tasks:
   all:
     desc: Build for distribution for all platforms
@@ -8,9 +28,11 @@ tasks:
       - task: Windows_64bit
       - task: Linux_32bit
       - task: Linux_64bit
-      - task: Linux_ARM
+      - task: Linux_ARMv6
+      - task: Linux_ARMv7
       - task: Linux_ARM64
       - task: macOS_64bit
+      - task: macOS_ARM64
 
   Windows_32bit:
     desc: Builds Windows 32 bit binaries
@@ -20,13 +42,14 @@ tasks:
       GO386: "softfloat"
     cmds:
       - |
-        go build -o {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }}.exe {{.LDFLAGS}}
-        zip {{ .DIST_DIR}}/{{ .PACKAGE_NAME }} {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }}.exe -j
-        zip {{ .DIST_DIR}}/{{ .PACKAGE_NAME }} LICENSE.txt -r
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
     vars:
-      PLATFORM_DIR: "windows32"
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_windows_386"
       PACKAGE_PLATFORM: "Windows_32bit"
-      PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.zip"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.zip"
 
   Windows_64bit:
     desc: Builds Windows 64 bit binaries
@@ -35,13 +58,14 @@ tasks:
       GOARCH: "amd64"
     cmds:
       - |
-        go build -o {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }}.exe {{.LDFLAGS}}
-        zip {{ .DIST_DIR}}/{{ .PACKAGE_NAME }} {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }}.exe -j
-        zip {{ .DIST_DIR}}/{{ .PACKAGE_NAME }} LICENSE.txt -r
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
     vars:
-      PLATFORM_DIR: "windows64"
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_windows_amd64"
       PACKAGE_PLATFORM: "Windows_64bit"
-      PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.zip"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.zip"
 
   Linux_32bit:
     desc: Builds Linux 32 bit binaries
@@ -51,12 +75,14 @@ tasks:
       GO386: "softfloat"
     cmds:
       - |
-        go build -o {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{.LDFLAGS}}
-        tar cz LICENSE.txt -C {{ .DIST_DIR}}/{{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -f {{ .DIST_DIR }}/{{ .PACKAGE_NAME }}
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt  -f {{.PACKAGE_NAME}}
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
     vars:
-      PLATFORM_DIR: "linux32"
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd32"
       PACKAGE_PLATFORM: "Linux_32bit"
-      PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
 
   Linux_64bit:
     desc: Builds Linux 64 bit binaries
@@ -65,26 +91,48 @@ tasks:
       GOARCH: "amd64"
     cmds:
       - |
-        go build -o {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{.LDFLAGS}}
-        tar cz LICENSE.txt -C {{ .DIST_DIR}}/{{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -f {{ .DIST_DIR }}/{{ .PACKAGE_NAME }}
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt  -f {{.PACKAGE_NAME}}
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
     vars:
-      PLATFORM_DIR: "linux64"
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd64"
       PACKAGE_PLATFORM: "Linux_64bit"
-      PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
+
+  Linux_ARMv7:
+    desc: Builds Linux ARMv7 binaries
+    env:
+      GOOS: "linux"
+      GOARCH: "arm"
+      GOARM: 7
+    cmds:
+      - |
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt  -f {{.PACKAGE_NAME}}
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
+    vars:
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
+      PACKAGE_PLATFORM: "Linux_ARMv7"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
 
-  Linux_ARM:
-    desc: Builds Linux ARM binaries
+  Linux_ARMv6:
+    desc: Builds Linux ARMv6 binaries
     env:
       GOOS: "linux"
       GOARCH: "arm"
+      GOARM: 6
     cmds:
       - |
-        go build -o {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{.LDFLAGS}}
-        tar cz LICENSE.txt -C {{ .DIST_DIR}}/{{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -f {{ .DIST_DIR }}/{{ .PACKAGE_NAME }}
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt  -f {{.PACKAGE_NAME}}
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
     vars:
-      PLATFORM_DIR: "linuxarm"
-      PACKAGE_PLATFORM: "Linux_ARM"
-      PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz"
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
+      PACKAGE_PLATFORM: "Linux_ARMv6"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
 
   Linux_ARM64:
     desc: Builds Linux ARM64 binaries
@@ -93,12 +141,14 @@ tasks:
       GOARCH: "arm64"
     cmds:
       - |
-        go build -o {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{.LDFLAGS}}
-        tar cz LICENSE.txt -C {{ .DIST_DIR}}/{{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -f {{ .DIST_DIR }}/{{ .PACKAGE_NAME }}
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt  -f {{.PACKAGE_NAME}}
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
     vars:
-      PLATFORM_DIR: "linuxarm64"
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64"
       PACKAGE_PLATFORM: "Linux_ARM64"
-      PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
 
   macOS_64bit:
     desc: Builds Mac OS X 64 bit binaries
@@ -107,12 +157,30 @@ tasks:
       GOARCH: "amd64"
     cmds:
       - |
-        go build -o {{ .DIST_DIR}}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{.LDFLAGS}}
-        tar cz LICENSE.txt -C {{ .DIST_DIR}}/{{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -f {{ .DIST_DIR }}/{{ .PACKAGE_NAME }}
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt  -f {{.PACKAGE_NAME}}
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
     vars:
-      PLATFORM_DIR: "macos64"
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_amd64"
       PACKAGE_PLATFORM: "macOS_64bit"
-      PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
+
+  macOS_ARM64:
+    desc: Builds Mac OS X ARM64 binaries
+    env:
+      GOOS: "darwin"
+      GOARCH: "arm64"
+    cmds:
+      - |
+        go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}
+        cd {{.DIST_DIR}}
+        tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt  -f {{.PACKAGE_NAME}}
+        sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
+    vars:
+      PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_arm64"
+      PACKAGE_PLATFORM: "macOS_ARM64"
+      PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
 
   generate-index-data:
     desc: Generates json for platform index

From 3873f0a78cc1d0d9e69e2f0abe548c3a08695469 Mon Sep 17 00:00:00 2001
From: Umberto Baldi <u.baldi@arduino.cc>
Date: Fri, 1 Jul 2022 15:10:25 +0200
Subject: [PATCH 3/8] uniform `publish-go-tester-task` to the assets repo: -
 add macos arm64 - differentiate linux arm into linux armv6, and linux armv7 -
 bump version of GO to 1.17 - bump upload/artifact action from 2 to 3 - add
 checksum upload - remove unnecessary line continuation escaping from workflow

---
 .github/workflows/publish-go-tester-task.yml | 36 ++++++++++++--------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/.github/workflows/publish-go-tester-task.yml b/.github/workflows/publish-go-tester-task.yml
index 7c2ee8c3..57cc0bab 100644
--- a/.github/workflows/publish-go-tester-task.yml
+++ b/.github/workflows/publish-go-tester-task.yml
@@ -1,14 +1,7 @@
 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
 name: Publish Tester Build
 
-env:
-  # See: https://github.com/actions/setup-go/tree/v2#readme
-  GO_VERSION: ^1.16.2
-  # As defined by the Taskfile's DIST_DIR variable
-  DIST_DIR: dist
-  BUILDS_ARTIFACT: build-artifacts
-
-# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
+# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
 on:
   create:
   push:
@@ -30,6 +23,13 @@ on:
   workflow_dispatch:
   repository_dispatch:
 
+env:
+  # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
+  GO_VERSION: ^1.16.2
+  # As defined by the Taskfile's DIST_DIR variable
+  DIST_DIR: dist
+  BUILDS_ARTIFACT: build-artifacts
+
 jobs:
   run-determination:
     runs-on: ubuntu-latest
@@ -41,9 +41,9 @@ jobs:
         run: |
           RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
           # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
-          if [[ \
-            "${{ github.event_name }}" != "create" || \
-            "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
+          if [[
+            "${{ github.event_name }}" != "create" ||
+            "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
           ]]; then
             # Run the other jobs.
             RESULT="true"
@@ -86,7 +86,7 @@ jobs:
 
       # Transfer builds to artifacts job
       - name: Upload combined builds artifact
-        uses: actions/upload-artifact@v2
+        uses: actions/upload-artifact@v3
         with:
           path: ${{ env.DIST_DIR }}
           name: ${{ env.BUILDS_ARTIFACT }}
@@ -99,16 +99,22 @@ jobs:
     strategy:
       matrix:
         artifact:
+          - path: "*checksums.txt"
+            name: checksums
           - path: "*Linux_32bit.tar.gz"
             name: Linux_X86-32
           - path: "*Linux_64bit.tar.gz"
             name: Linux_X86-64
-          - path: "*Linux_ARM.tar.gz"
-            name: Linux_ARM
           - path: "*Linux_ARM64.tar.gz"
             name: Linux_ARM64
+          - path: "*Linux_ARMv6.tar.gz"
+            name: Linux_ARMv6
+          - path: "*Linux_ARMv7.tar.gz"
+            name: Linux_ARMv7
           - path: "*macOS_64bit.tar.gz"
             name: macOS_64
+          - path: "*macOS_ARM64.tar.gz"
+            name: macOS_ARM64
           - path: "*Windows_32bit.zip"
             name: Windows_X86-32
           - path: "*Windows_64bit.zip"
@@ -122,7 +128,7 @@ jobs:
           path: ${{ env.BUILDS_ARTIFACT }}
 
       - name: Upload individual build artifact
-        uses: actions/upload-artifact@v2
+        uses: actions/upload-artifact@v3
         with:
           path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }}
           name: ${{ matrix.artifact.name }}

From f1040f340a6b157bb711c3c2b417271ae272c688 Mon Sep 17 00:00:00 2001
From: Umberto Baldi <u.baldi@arduino.cc>
Date: Thu, 30 Jun 2022 16:53:20 +0200
Subject: [PATCH 4/8] uniform `release-go-crosscompile-task` to the assets
 repo: - add macos arm64 - differentiate linux arm into linux armv6, and linux
 armv7 - bump version of GO to 1.17 - bump upload/artifact action from 2 to 3
 - add checksum upload - remove unnecessary line continuation escaping from
 workflow - rename workflow - remove `gon.config.hcl` since now is hardcoded
 in the workflow

---
 ...k.yml => release-go-crosscompile-task.yml} | 87 +++++++++++++++----
 gon.config.hcl                                | 14 ---
 2 files changed, 71 insertions(+), 30 deletions(-)
 rename .github/workflows/{release-go-task.yml => release-go-crosscompile-task.yml} (61%)
 delete mode 100644 gon.config.hcl

diff --git a/.github/workflows/release-go-task.yml b/.github/workflows/release-go-crosscompile-task.yml
similarity index 61%
rename from .github/workflows/release-go-task.yml
rename to .github/workflows/release-go-crosscompile-task.yml
index 35dc2cb5..aa241b55 100644
--- a/.github/workflows/release-go-task.yml
+++ b/.github/workflows/release-go-crosscompile-task.yml
@@ -1,4 +1,4 @@
-# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-task.md
+# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-crosscompile-task.md
 name: Release
 
 env:
@@ -9,7 +9,7 @@ env:
   # The project's folder on Arduino's download server for uploading builds
   AWS_PLUGIN_TARGET: /arduino-fwuploader/
   ARTIFACT_NAME: dist
-  # See: https://github.com/actions/setup-go/tree/v2#readme
+  # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
   GO_VERSION: ^1.16.2
 
 on:
@@ -50,15 +50,30 @@ jobs:
         run: task dist:all
 
       - name: Upload artifacts
-        uses: actions/upload-artifact@v2
+        uses: actions/upload-artifact@v3
         with:
           if-no-files-found: error
           name: ${{ env.ARTIFACT_NAME }}
           path: ${{ env.DIST_DIR }}
 
   notarize-macos:
+    name: Notarize ${{ matrix.artifact.name }}
     runs-on: macos-latest
     needs: create-release-artifacts
+    outputs:
+      checksum-darwin_amd64: ${{ steps.re-package.outputs.checksum-darwin_amd64 }}
+      checksum-darwin_arm64: ${{ steps.re-package.outputs.checksum-darwin_arm64 }}
+
+    env:
+      GON_CONFIG_PATH: gon.config.hcl
+
+    strategy:
+      matrix:
+        artifact:
+          - name: darwin_amd64
+            path: "macOS_64bit.tar.gz"
+          - name: darwin_arm64
+            path: "macOS_ARM64.tar.gz"
 
     steps:
       - name: Checkout repository
@@ -98,38 +113,66 @@ jobs:
           wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
           unzip gon_macos.zip -d /usr/local/bin
 
+      - name: Write gon config to file
+        # gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
+        run: |
+          cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
+          # See: https://github.com/mitchellh/gon#configuration-file
+          source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
+          bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
+
+          sign {
+            application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
+          }
+
+          # Ask Gon for zip output to force notarization process to take place.
+          # The CI will ignore the zip output, using the signed binary only.
+          zip {
+            output_path = "unused.zip"
+          }
+          EOF
+
       - name: Sign and notarize binary
         env:
           AC_USERNAME: ${{ secrets.AC_USERNAME }}
           AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
         run: |
-          gon gon.config.hcl
+          gon "${{ env.GON_CONFIG_PATH }}"
 
-      - name: Re-package binary
+      - name: Re-package binary and output checksum
+        id: re-package
+        working-directory: ${{ env.DIST_DIR }}
         # This step performs the following:
         # 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
+        # 2. Recalculate package checksum
+        # 3. Output the new checksum to include in the nnnnnn-checksums.txt file
+        #    (it cannot be done there because of workflow job parallelization)
         run: |
-          # GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
+          # GitHub's upload/download-artifact actions don't preserve file permissions,
           # so we need to add execution permission back until the action is made to do this.
-          chmod +x ${{ env.DIST_DIR }}/macos64/${{ env.PROJECT_NAME }}
+          chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
           TAG="${GITHUB_REF/refs\/tags\//}"
-          tar -czvf "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz" \
-            LICENSE.txt \
-            -C ${{ env.DIST_DIR }}/macos64/ ${{ env.PROJECT_NAME }}
+          PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
+          tar -czvf "$PACKAGE_FILENAME" \
+          -C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
+          -C ../../ LICENSE.txt
+          CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
+          echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
+          echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
 
       - name: Upload artifacts
-        uses: actions/upload-artifact@v2
+        uses: actions/upload-artifact@v3
         with:
           if-no-files-found: error
           name: ${{ env.ARTIFACT_NAME }}
-          path: ${{ env.DIST_DIR }}
+          path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
 
   create-release:
     runs-on: ubuntu-latest
     needs: notarize-macos
 
     steps:
-      - name: Checkout
+      - name: Checkout # we need package_index.template
         uses: actions/checkout@v3
 
       - name: Download artifact
@@ -149,13 +192,23 @@ jobs:
         # would be calculated since the binary is modified during notarization
         run: task dist:generate-index-data
 
+      - name: Update checksum
+        run: |
+          declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
+          for checksum_line in "${checksum_lines[@]}"
+          do
+            CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
+            PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
+            perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM}  ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
+          done
+
       - name: Identify Prerelease
         # This is a workaround while waiting for create-release action
         # to implement auto pre-release based on tag
         id: prerelease
         run: |
-          wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
-          unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
+          wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
+          unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
           if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
 
       - name: Create Github Release and upload artifacts
@@ -165,7 +218,9 @@ jobs:
           bodyFile: ${{ env.DIST_DIR }}/CHANGELOG.md
           draft: false
           prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
-          artifacts: ${{ env.DIST_DIR }}/arduino-fwuploader*,${{ env.DIST_DIR }}/package_index.json
+          # NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
+          # (all the files we need are in the DIST_DIR root)
+          artifacts: ${{ env.DIST_DIR }}/*
 
       - name: Upload release files on Arduino downloads servers
         uses: docker://plugins/s3
diff --git a/gon.config.hcl b/gon.config.hcl
deleted file mode 100644
index 6d4b71ed..00000000
--- a/gon.config.hcl
+++ /dev/null
@@ -1,14 +0,0 @@
-# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/general/gon.config.hcl
-# See: https://github.com/mitchellh/gon#configuration-file
-source = ["dist/macos64/arduino-fwuploader"]
-bundle_id = "cc.arduino.arduino-fwuploader"
-
-sign {
-  application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
-}
-
-# Ask Gon for zip output to force notarization process to take place.
-# The CI will ignore the zip output, using the signed binary only.
-zip {
-  output_path = "unused.zip"
-}

From 3f546d395a61db00c272f2688193a90bc242b53f Mon Sep 17 00:00:00 2001
From: Umberto Baldi <u.baldi@arduino.cc>
Date: Thu, 30 Jun 2022 16:44:49 +0200
Subject: [PATCH 5/8] add support for darwin arm64 package index generation

---
 DistTasks.yml                      | 6 ++++++
 extras/package_index.json.template | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/DistTasks.yml b/DistTasks.yml
index 47b2242b..c5d8fa49 100644
--- a/DistTasks.yml
+++ b/DistTasks.yml
@@ -199,6 +199,8 @@ tasks:
         sh: sha256sum {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_ARM64.tar.gz | cut -f1 -d " "
       OSX64_SHA:
         sh: sha256sum {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_macOS_64bit.tar.gz | cut -f1 -d " "
+      OSXARM64_SHA:
+        sh: sha256sum {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_macOS_ARM64.tar.gz | cut -f1 -d " "
       WINDOWS32_SIZE:
         sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Windows_32bit.zip | cut -f5 -d " "
       WINDOWS64_SIZE:
@@ -213,6 +215,8 @@ tasks:
         sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_Linux_ARM64.tar.gz | cut -f5 -d " "
       OSX64_SIZE:
         sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_macOS_64bit.tar.gz | cut -f5 -d " "
+      OSXARM64_SIZE:
+        sh: ls -la {{ .DIST_DIR }}/{{ .PROJECT_NAME }}_{{ .VERSION }}_macOS_ARM64.tar.gz | cut -f5 -d " "
     cmds:
       - |
         cat extras/package_index.json.template |
@@ -228,6 +232,8 @@ tasks:
         sed "s/%%LINUXARM64_SIZE%%/{{ .LINUXARM64_SIZE }}/" |
         sed "s/%%OSX64_SHA%%/{{ .OSX64_SHA }}/" |
         sed "s/%%OSX64_SIZE%%/{{ .OSX64_SIZE }}/" |
+        sed "s/%%OSXARM64_SHA%%/{{ .OSXARM64_SHA }}/" |
+        sed "s/%%OSXARM64_SIZE%%/{{ .OSXARM64_SIZE }}/" |
         sed "s/%%WINDOWS32_SHA%%/{{ .WINDOWS32_SHA }}/" |
         sed "s/%%WINDOWS32_SIZE%%/{{ .WINDOWS32_SIZE }}/" |
         sed "s/%%WINDOWS64_SHA%%/{{ .WINDOWS64_SHA }}/" |
diff --git a/extras/package_index.json.template b/extras/package_index.json.template
index f9b81443..d6fc6076 100644
--- a/extras/package_index.json.template
+++ b/extras/package_index.json.template
@@ -37,6 +37,13 @@
               "checksum": "SHA-256:%%OSX64_SHA%%",
               "size": "%%OSX64_SIZE%%"
             },
+            {
+              "host": "aarch64-apple-darwin",
+              "url": "http://downloads.arduino.cc/arduino-fwuploader/%%FILENAME%%_%%VERSION%%_macOS_ARM64.tar.gz",
+              "archiveFileName": "%%FILENAME%%_%%VERSION%%_macOS_ARM64.tar.gz",
+              "checksum": "SHA-256:%%OSXARM64_SHA%%",
+              "size": "%%OSXARM64_SIZE%%"
+            },
             {
               "host": "arm-linux-gnueabihf",
               "url": "http://downloads.arduino.cc/arduino-fwuploader/%%FILENAME%%_%%VERSION%%_Linux_ARMv6.tar.gz",

From 1ea23f5f059f5214d166294e58c9f09744f49ffb Mon Sep 17 00:00:00 2001
From: Umberto Baldi <u.baldi@arduino.cc>
Date: Fri, 1 Jul 2022 15:10:46 +0200
Subject: [PATCH 6/8] update doc

---
 docs/installation.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/installation.md b/docs/installation.md
index f230ecb8..322a85b7 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -12,6 +12,6 @@ To build we use [task](https://taskfile.dev/) for simplicity. From the sources r
 task dist:<OS>_<ARCH>
 ```
 
-Where <OS> could be one of: `macOS`,`Windows`,`Linux`. And <ARCH>: `32bit`, `64bit`, `ARM` or `ARM64`
+Where <OS> could be one of: `macOS`,`Windows`,`Linux`. And <ARCH>: `32bit`, `64bit`, `ARMv6`, `ARMv7` or `ARM64`
 
 This will create the `arduino-fwuploader` executable.

From 0ea816edf927acb4ea3b83d34fc8f57f78848a3b Mon Sep 17 00:00:00 2001
From: Umberto Baldi <u.baldi@arduino.cc>
Date: Fri, 1 Jul 2022 15:27:57 +0200
Subject: [PATCH 7/8] disable s3 upload (for testing only)

---
 .../workflows/release-go-crosscompile-task.yml | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml
index aa241b55..039cdd7d 100644
--- a/.github/workflows/release-go-crosscompile-task.yml
+++ b/.github/workflows/release-go-crosscompile-task.yml
@@ -222,12 +222,12 @@ jobs:
           # (all the files we need are in the DIST_DIR root)
           artifacts: ${{ env.DIST_DIR }}/*
 
-      - name: Upload release files on Arduino downloads servers
-        uses: docker://plugins/s3
-        env:
-          PLUGIN_SOURCE: "${{ env.DIST_DIR }}/arduino-fwuploader*"
-          PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
-          PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
-          PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
-          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
-          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+      # - name: Upload release files on Arduino downloads servers
+      #   uses: docker://plugins/s3
+      #   env:
+      #     PLUGIN_SOURCE: "${{ env.DIST_DIR }}/arduino-fwuploader*"
+      #     PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
+      #     PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
+      #     PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
+      #     AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
+      #     AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

From b9297260e7ba7fa7545789bccdef0223dc7c73ba Mon Sep 17 00:00:00 2001
From: Umberto Baldi <u.baldi@arduino.cc>
Date: Fri, 1 Jul 2022 15:28:03 +0200
Subject: [PATCH 8/8] Revert "disable s3 upload (for testing only)"

This reverts commit 5ddd847d89fa3dd43f4499c48b4583b2e8f4f1ea.
---
 .../workflows/release-go-crosscompile-task.yml | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml
index 039cdd7d..aa241b55 100644
--- a/.github/workflows/release-go-crosscompile-task.yml
+++ b/.github/workflows/release-go-crosscompile-task.yml
@@ -222,12 +222,12 @@ jobs:
           # (all the files we need are in the DIST_DIR root)
           artifacts: ${{ env.DIST_DIR }}/*
 
-      # - name: Upload release files on Arduino downloads servers
-      #   uses: docker://plugins/s3
-      #   env:
-      #     PLUGIN_SOURCE: "${{ env.DIST_DIR }}/arduino-fwuploader*"
-      #     PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
-      #     PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
-      #     PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
-      #     AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
-      #     AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+      - name: Upload release files on Arduino downloads servers
+        uses: docker://plugins/s3
+        env:
+          PLUGIN_SOURCE: "${{ env.DIST_DIR }}/arduino-fwuploader*"
+          PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
+          PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
+          PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
+          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
+          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}