diff --git a/other/installation-script/installation.md b/other/installation-script/installation.md index 72129996..41b11d7a 100644 --- a/other/installation-script/installation.md +++ b/other/installation-script/installation.md @@ -46,7 +46,8 @@ in your [`PATH`](https://wikipedia.org/wiki/PATH%5F%28variable%29) or add the TO | 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/TODO_REPO_NAME/TODO_REPO_NAME_latest_Linux_64bit.tar.gz [linux32]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Linux_32bit.tar.gz @@ -54,7 +55,8 @@ in your [`PATH`](https://wikipedia.org/wiki/PATH%5F%28variable%29) or add the TO [linuxarm32]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Linux_ARMv7.tar.gz [windows64]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Windows_64bit.zip [windows32]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_Windows_32bit.zip -[macos]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_macOS_64bit.tar.gz +[macos64]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_latest_macOS_64bit.tar.gz +[macosarm64]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_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/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Linux_64bit.tar.gz [linux32-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_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/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Linux_ARMv7.tar.gz [windows64-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Windows_64bit.zip [windows32-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_Windows_32bit.zip -[macos-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_macOS_64bit.tar.gz +[macos64-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/nightly/TODO_REPO_NAME_nightly-latest_macOS_64bit.tar.gz +[macosarm64-nightly]: https://downloads.arduino.cc/TODO_REPO_NAME/TODO_REPO_NAME_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/workflow-templates/assets/general/gon.config.hcl b/workflow-templates/assets/general/gon.config.hcl deleted file mode 100644 index 608ce582..00000000 --- a/workflow-templates/assets/general/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 = [TODO_SOURCE_PATH] -bundle_id = TODO_BUNDLE_ID - -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" -} diff --git a/workflow-templates/assets/release-go-crosscompile-task/DistTasks.yml b/workflow-templates/assets/release-go-crosscompile-task/DistTasks.yml index c5961148..51e35753 100644 --- a/workflow-templates/assets/release-go-crosscompile-task/DistTasks.yml +++ b/workflow-templates/assets/release-go-crosscompile-task/DistTasks.yml @@ -32,6 +32,7 @@ tasks: - task: Linux_ARMv7 - task: Linux_ARM64 - task: macOS_64bit + - task: macOS_ARM64 Windows_32bit: desc: Builds Windows 32 bit binaries @@ -164,3 +165,19 @@ tasks: PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_amd64" PACKAGE_PLATFORM: "macOS_64bit" 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" diff --git a/workflow-templates/assets/release-go-task/DistTasks.yml b/workflow-templates/assets/release-go-task/DistTasks.yml index ee809286..e81131ff 100644 --- a/workflow-templates/assets/release-go-task/DistTasks.yml +++ b/workflow-templates/assets/release-go-task/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/workflow-templates/dependabot/workflow-template-copies/.github/workflows/publish-go-nightly-task.yml b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/publish-go-nightly-task.yml index 920911b6..cec8754b 100644 --- a/workflow-templates/dependabot/workflow-template-copies/.github/workflows/publish-go-nightly-task.yml +++ b/workflow-templates/dependabot/workflow-template-copies/.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/workflow-templates/dependabot/workflow-template-copies/.github/workflows/publish-go-tester-task.yml b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/publish-go-tester-task.yml index 560bdd1f..373624df 100644 --- a/workflow-templates/dependabot/workflow-template-copies/.github/workflows/publish-go-tester-task.yml +++ b/workflow-templates/dependabot/workflow-template-copies/.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/workflow-templates/dependabot/workflow-template-copies/.github/workflows/release-go-crosscompile-task.yml b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/release-go-crosscompile-task.yml index d57b5e93..31ddd140 100644 --- a/workflow-templates/dependabot/workflow-template-copies/.github/workflows/release-go-crosscompile-task.yml +++ b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/release-go-crosscompile-task.yml @@ -57,8 +57,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 @@ -98,38 +113,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 @@ -142,6 +178,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/workflow-templates/dependabot/workflow-template-copies/.github/workflows/release-go-task.yml b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/release-go-task.yml index e8af0405..b24bfc3f 100644 --- a/workflow-templates/dependabot/workflow-template-copies/.github/workflows/release-go-task.yml +++ b/workflow-templates/dependabot/workflow-template-copies/.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/workflow-templates/publish-go-nightly-task.md b/workflow-templates/publish-go-nightly-task.md index 7835c1c6..71b8ce73 100644 --- a/workflow-templates/publish-go-nightly-task.md +++ b/workflow-templates/publish-go-nightly-task.md @@ -50,7 +50,7 @@ Add CI workflow to publish nightly builds On a daily schedule: - Build the project for all supported platforms. -- Sign and notarize the macOS build. +- Sign and notarize the macOS builds. - Upload the builds to Arduino's downloads server. This will enable everyone to participate in the project's development via beta testing. @@ -62,7 +62,7 @@ This will enable everyone to participate in the project's development via beta t On a daily schedule: - Build the project for all supported platforms. -- Use [gon](https://github.com/mitchellh/gon) to sign and notarize the macOS build. +- Use [gon](https://github.com/mitchellh/gon) to sign and notarize the macOS builds. - Upload the builds to Arduino's downloads server. This will enable everyone to participate in the project's development via beta testing. diff --git a/workflow-templates/publish-go-nightly-task.yml b/workflow-templates/publish-go-nightly-task.yml index 920911b6..cec8754b 100644 --- a/workflow-templates/publish-go-nightly-task.yml +++ b/workflow-templates/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/workflow-templates/publish-go-tester-task.yml b/workflow-templates/publish-go-tester-task.yml index 560bdd1f..373624df 100644 --- a/workflow-templates/publish-go-tester-task.yml +++ b/workflow-templates/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/workflow-templates/release-go-crosscompile-task.md b/workflow-templates/release-go-crosscompile-task.md index 2fed1f2f..556a377d 100644 --- a/workflow-templates/release-go-crosscompile-task.md +++ b/workflow-templates/release-go-crosscompile-task.md @@ -16,8 +16,6 @@ Install the [`release-go-crosscompile-task.yml`](release-go-crosscompile-task.ym - Install to: repository root (or merge into the existing `Taskfile.yml`). - [`DistTasks.yml`](assets/release-go-crosscompile-task/DistTasks.yml) - general purpose tasks for making production builds of Go projects using golang cross-compile. - Install to: repository root -- [`gon.config.hcl`](assets/general/gon.config.hcl) - [gon](https://github.com/mitchellh/gon) configuration file for macOS signing and notarization. - - Install to: repository root - [Installation script and documentation](../other/installation-script/README.md) ### Configuration @@ -37,14 +35,7 @@ The following project-specific variables must be set/configured in `release-go-c - `PROJECT_NAME` - `AWS_PLUGIN_TARGET` -- `GO_VERSION`: version of Go used for development of the project - -#### gon - -The following project-specific variables must be set in `gon.config.hcl`: - -- `source` -- `bundle_id` +- `GO_VERSION`: version of Go used for development of the project, use at least [GO 1.16 to be able to use 64-bit ARM architecture on macOS](https://tip.golang.org/doc/go1.16#ports) #### Repository secrets @@ -87,7 +78,7 @@ Add CI workflow to publish releases On every push of a tag named with a version format: - Build the project for all supported platforms. -- Sign and notarize the macOS build. +- Sign and notarize the macOS builds. - Create a GitHub release. - Builds and checksums are attached as release assets - A changelog generated from the commit history is added to the release description @@ -101,7 +92,7 @@ On every push of a tag named with a version format: On every push of a tag named with a version format: - Build the project for all supported platforms. -- Use [gon](https://github.com/mitchellh/gon) to sign and notarize the macOS build. +- Use [gon](https://github.com/mitchellh/gon) to sign and notarize the macOS builds. - Create a [GitHub release](https://docs.github.com/repositories/releasing-projects-on-github/about-releases). - Builds and checksums are attached as release assets - A changelog generated by [`arduino/create-changelog`](https://github.com/arduino/create-changelog) from the commit history is added to the release description diff --git a/workflow-templates/release-go-crosscompile-task.yml b/workflow-templates/release-go-crosscompile-task.yml index d57b5e93..31ddd140 100644 --- a/workflow-templates/release-go-crosscompile-task.yml +++ b/workflow-templates/release-go-crosscompile-task.yml @@ -57,8 +57,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 @@ -98,38 +113,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 @@ -142,6 +178,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/workflow-templates/release-go-task.md b/workflow-templates/release-go-task.md index 80554f46..50f7598e 100644 --- a/workflow-templates/release-go-task.md +++ b/workflow-templates/release-go-task.md @@ -16,8 +16,6 @@ Install the [`release-go-task.yml`](release-go-task.yml) GitHub Actions workflow - Install to: repository root (or merge into the existing `Taskfile.yml`). - [`DistTasks.yml`](assets/release-go-task/DistTasks.yml) - general purpose tasks for making production builds of Go projects using cgo and [elastic docker containers](https://github.com/elastic/golang-crossbuild). - Install to: repository root -- [`gon.config.hcl`](assets/general/gon.config.hcl) - [gon](https://github.com/mitchellh/gon) configuration file for macOS signing and notarization. - - Install to: repository root - [Installation script and documentation](../other/installation-script/README.md) ### Configuration @@ -38,13 +36,6 @@ The following project-specific variables must be set in `release-go-task.yml`: - `PROJECT_NAME` - `AWS_PLUGIN_TARGET` -#### gon - -The following project-specific variables must be set in `gon.config.hcl`: - -- `source` -- `bundle_id` - #### Repository secrets The following [repository secrets](https://docs.github.com/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) must be defined: @@ -86,7 +77,7 @@ Add CI workflow to publish releases On every push of a tag named with a version format: - Build the project for all supported platforms. -- Sign and notarize the macOS build. +- Sign and notarize the macOS builds. - Create a GitHub release. - Builds and checksums are attached as release assets - A changelog generated from the commit history is added to the release description @@ -100,7 +91,7 @@ On every push of a tag named with a version format: On every push of a tag named with a version format: - Build the project for all supported platforms. -- Use [gon](https://github.com/mitchellh/gon) to sign and notarize the macOS build. +- Use [gon](https://github.com/mitchellh/gon) to sign and notarize the macOS builds. - Create a [GitHub release](https://docs.github.com/repositories/releasing-projects-on-github/about-releases). - Builds and checksums are attached as release assets - A changelog generated by [`arduino/create-changelog`](https://github.com/arduino/create-changelog) from the commit history is added to the release description diff --git a/workflow-templates/release-go-task.yml b/workflow-templates/release-go-task.yml index e8af0405..b24bfc3f 100644 --- a/workflow-templates/release-go-task.yml +++ b/workflow-templates/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