From e6c0b7bd1d19d41c8350245789caf4c8f602cb86 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 30 Jun 2022 03:56:21 -0700 Subject: [PATCH 1/5] Update redirecting reference links in workflows Even though these links were still reaching the intended page, it is best not to rely on redirects continuing to work indefinitely. --- .github/workflows/publish-go-nightly-task.yml | 2 +- .github/workflows/publish-go-tester-task.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-go-nightly-task.yml b/.github/workflows/publish-go-nightly-task.yml index 5bc4eddf0..98a83acd1 100644 --- a/.github/workflows/publish-go-nightly-task.yml +++ b/.github/workflows/publish-go-nightly-task.yml @@ -10,7 +10,7 @@ env: AWS_PLUGIN_TARGET: /arduino-lint/ ARTIFACT_NAME: dist -# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows on: schedule: # run every day at 1AM diff --git a/.github/workflows/publish-go-tester-task.yml b/.github/workflows/publish-go-tester-task.yml index c3bdeacab..6c21a09ff 100644 --- a/.github/workflows/publish-go-tester-task.yml +++ b/.github/workflows/publish-go-tester-task.yml @@ -1,7 +1,7 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md name: Publish Tester Build -# 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: From f0e7fd4bb7b3b8e1bc9a114e06080249296f741a Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 30 Jun 2022 03:58:14 -0700 Subject: [PATCH 2/5] Remove unnecessary line continuation escaping from workflow It is often necessary to escape the newline for continuation when breaking shell commands into multiple lines for readability. However, if a line break occurs in a shell command in an unterminated command, the continuation is implicit. The escaping in these shell commands was unnecessary and only made them a bit more cryptic, since the brackets already clearly indicate the structure --- .github/workflows/publish-go-tester-task.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-go-tester-task.yml b/.github/workflows/publish-go-tester-task.yml index 6c21a09ff..560bdd1f6 100644 --- a/.github/workflows/publish-go-tester-task.yml +++ b/.github/workflows/publish-go-tester-task.yml @@ -39,9 +39,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" From db83455c7dc18a27cbcbaf50807195acb5d97c58 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 30 Jun 2022 03:59:36 -0700 Subject: [PATCH 3/5] Bump semver-tool to 3.2.0 The 3.2.0 is already outdated, but this version has been well tested and used for some time in other projects. So this is intended to at least bring all the workflows into sync. --- .github/workflows/release-go-task.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-go-task.yml b/.github/workflows/release-go-task.yml index ee24e7d5f..7c8369ce4 100644 --- a/.github/workflows/release-go-task.yml +++ b/.github/workflows/release-go-task.yml @@ -140,8 +140,8 @@ jobs: # 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 From 73e7a1953b3e63b516fae0d0a57980b283816920 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 30 Jun 2022 04:02:02 -0700 Subject: [PATCH 4/5] Correct folder name in build taskfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A copy/paste error resulted in the same folder name being used for the Linux ARM 64-bit build as for the Linux ARM v6 build. Although that did not cause any noticeable problems in this project's usage, it can in others. For example: ``` mkdir: cannot create directory ‘serial-monitor_linux_arm_6’: File exists task: Failed to run task "dist:all": task: Failed to run task "dist:Linux_ARM64": exit status 1 ``` It also causes an unexpected structure in the "dist" output, which is not typically used for anything, but might still cause confusion during unrelated development or troubleshooting. --- DistTasks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DistTasks.yml b/DistTasks.yml index 48bfd459c..ee809286e 100644 --- a/DistTasks.yml +++ b/DistTasks.yml @@ -210,7 +210,7 @@ tasks: sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}} vars: - PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6" + PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64" BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}" BUILD_PLATFORM: "linux/arm64" CONTAINER_TAG: "{{.GO_VERSION}}-arm" From 4164141fc150ac8c49cfbbee23e05d74c354be0a Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 30 Jun 2022 04:06:23 -0700 Subject: [PATCH 5/5] Add macOS ARM 64-bit build target Previously, the only macOS build of the application was for x86-64 host architecture. That build was also compatible for use on Apple M1 based machines via Rosetta 2 translation. However, a native ARM 64-bit build is optimum for use on these machines. --- .github/workflows/publish-go-nightly-task.yml | 77 +++++++++++++++---- .github/workflows/publish-go-tester-task.yml | 2 + .github/workflows/release-go-task.yml | 76 ++++++++++++++---- DistTasks.yml | 23 ++++++ docs/installation.md | 12 ++- gon.config.hcl | 14 ---- 6 files changed, 156 insertions(+), 48 deletions(-) delete mode 100644 gon.config.hcl diff --git a/.github/workflows/publish-go-nightly-task.yml b/.github/workflows/publish-go-nightly-task.yml index 98a83acd1..4c7808b2c 100644 --- a/.github/workflows/publish-go-nightly-task.yml +++ b/.github/workflows/publish-go-nightly-task.yml @@ -45,9 +45,25 @@ jobs: path: ${{ env.DIST_DIR }} notarize-macos: + name: Notarize ${{ matrix.artifact.name }} runs-on: macos-latest needs: create-nightly-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 uses: actions/checkout@v3 @@ -86,38 +102,59 @@ 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 }}" <> $GITHUB_ENV + echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE" - name: Upload artifacts 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 }} publish-nightly: runs-on: ubuntu-latest @@ -130,6 +167,16 @@ jobs: name: ${{ env.ARTIFACT_NAME }} path: ${{ env.DIST_DIR }} + - 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: Upload release files on Arduino downloads servers uses: docker://plugins/s3 env: diff --git a/.github/workflows/publish-go-tester-task.yml b/.github/workflows/publish-go-tester-task.yml index 560bdd1f6..373624df7 100644 --- a/.github/workflows/publish-go-tester-task.yml +++ b/.github/workflows/publish-go-tester-task.yml @@ -106,6 +106,8 @@ jobs: 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" diff --git a/.github/workflows/release-go-task.yml b/.github/workflows/release-go-task.yml index 7c8369ce4..5affbf47a 100644 --- a/.github/workflows/release-go-task.yml +++ b/.github/workflows/release-go-task.yml @@ -50,8 +50,23 @@ jobs: 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 @@ -91,38 +106,59 @@ 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 }}" <> $GITHUB_ENV + echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE" - name: Upload artifacts 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 @@ -135,6 +171,16 @@ jobs: name: ${{ env.ARTIFACT_NAME }} path: ${{ env.DIST_DIR }} + - 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 diff --git a/DistTasks.yml b/DistTasks.yml index ee809286e..e81131ffa 100644 --- a/DistTasks.yml +++ b/DistTasks.yml @@ -34,6 +34,7 @@ tasks: - task: Linux_ARMv7 - task: Linux_ARM64 - task: macOS_64bit + - task: macOS_ARM64 Windows_32bit: desc: Builds Windows 32 bit binaries @@ -251,3 +252,25 @@ tasks: CONTAINER_TAG: "{{.GO_VERSION}}-darwin-debian10" PACKAGE_PLATFORM: "macOS_64bit" PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz" + + macOS_ARM64: + desc: Builds Mac OS X ARM64 binaries + dir: "{{.DIST_DIR}}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{.CONTAINER}}:{{.CONTAINER_TAG}} \ + --build-cmd "{{.BUILD_COMMAND}}" \ + -p "{{.BUILD_PLATFORM}}" + + 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" + BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}" + BUILD_PLATFORM: "darwin/arm64" + CONTAINER_TAG: "{{.GO_VERSION}}-darwin-arm64-debian10" + PACKAGE_PLATFORM: "macOS_ARM64" + PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz" diff --git a/docs/installation.md b/docs/installation.md index 1a9cf0289..0cc518f66 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -46,7 +46,8 @@ your `PATH` environment variable. | Linux | [32 bit][linux32] | [64 bit][linux64] | | Linux ARM | [32 bit][linuxarm32] | [64 bit][linuxarm64] | | Windows | [32 bit][windows32] | [64 bit][windows64] | -| macOS | | [64 bit][macos] | +| macOS | | [64 bit][macos64] | +| macOS ARM | | [64 bit][macosarm64] | [linux64]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Linux_64bit.tar.gz [linux32]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Linux_32bit.tar.gz @@ -54,7 +55,8 @@ your `PATH` environment variable. [linuxarm32]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Linux_ARMv7.tar.gz [windows64]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Windows_64bit.zip [windows32]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_Windows_32bit.zip -[macos]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_macOS_64bit.tar.gz +[macos64]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_macOS_64bit.tar.gz +[macosarm64]: https://downloads.arduino.cc/arduino-lint/arduino-lint_latest_macOS_ARM64.tar.gz ### Previous versions @@ -70,7 +72,8 @@ get the latest nightly build available for the supported platform, use the follo | Linux | [32 bit][linux32-nightly] | [64 bit][linux64-nightly] | | Linux ARM | [32 bit][linuxarm32-nightly] | [64 bit][linuxarm64-nightly] | | Windows | [32 bit][windows32-nightly] | [64 bit][windows64-nightly] | -| macOS | | [64 bit][macos-nightly] | +| macOS | | [64 bit][macos64-nightly] | +| macOS ARM | | [64 bit][macosarm64-nightly] | [linux64-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Linux_64bit.tar.gz [linux32-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Linux_32bit.tar.gz @@ -78,7 +81,8 @@ get the latest nightly build available for the supported platform, use the follo [linuxarm32-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Linux_ARMv7.tar.gz [windows64-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Windows_64bit.zip [windows32-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_Windows_32bit.zip -[macos-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_macOS_64bit.tar.gz +[macos64-nightly]: https://downloads.arduino.cc/arduino-lint/nightly/arduino-lint_nightly-latest_macOS_64bit.tar.gz +[macosarm64-nightly]: https://downloads.arduino.cc/arduino-lint/arduino-lint_nightly-latest_macOS_ARM64.tar.gz > These links return a `302: Found` response, redirecting to latest generated builds by replacing `latest` with the > latest available build date, using the format YYYYMMDD (i.e for 2019-08-06 `latest` is replaced with `20190806` ) diff --git a/gon.config.hcl b/gon.config.hcl deleted file mode 100644 index 92cc9221f..000000000 --- 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/arduino-lint_osx_darwin_amd64/arduino-lint"] -bundle_id = "cc.arduino.arduino-lint" - -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" -}