Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribution fixes for MacOS #172

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions .github/workflows/release-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
run: |
gon gon.config.hcl

- name: Re-package binary and update checksum
- name: Re-package amd64 binary and update checksum
# This step performs the following:
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
# 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
Expand All @@ -118,6 +118,25 @@ jobs:
-e "s/.*${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/${CHECKSUM} ${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/g;" \
${{ env.DIST_DIR }}/*-checksums.txt

- name: Re-package ARM64 binary and update checksum
# This step performs the following:
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
# 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
run: |
# GitHub's upload/download-artifact@v4 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 }}/${{ env.PROJECT_NAME }}_osx_darwin_arm64/${{ env.PROJECT_NAME }}
TAG="${GITHUB_REF/refs\/tags\//}"
tar -czvf "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_ARM64.tar.gz" \
-C ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_arm64/ ${{ env.PROJECT_NAME }} \
-C ../../ LICENSE.txt
CHECKSUM="$(shasum -a 256 ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_ARM64.tar.gz | cut -d " " -f 1)"
perl \
-pi \
-w \
-e "s/.*${{ env.PROJECT_NAME }}_${TAG}_macOS_ARM64.tar.gz/${CHECKSUM} ${{ env.PROJECT_NAME }}_${TAG}_macOS_ARM64.tar.gz/g;" \
${{ env.DIST_DIR }}/*-checksums.txt

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -156,14 +175,3 @@ jobs:
# 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 }}/*

# TODO
# - name: Upload release files on Arduino downloads servers
# uses: docker://plugins/s3
# env:
# PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
# 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 }}
31 changes: 27 additions & 4 deletions DistTasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ tasks:
- task: Linux_ARMv7
- task: Linux_ARM64
- task: macOS_64bit
- task: macOS_ARM64

Windows_32bit:
desc: Builds Windows 32 bit binaries
Expand Down Expand Up @@ -168,7 +169,7 @@ tasks:

vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}} -buildvcs=false"
BUILD_PLATFORM: "linux/armv6"
CONTAINER_TAG: "{{.GO_VERSION}}-armel-debian12"
PACKAGE_PLATFORM: "Linux_ARMv6"
Expand Down Expand Up @@ -197,7 +198,7 @@ tasks:
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

macOS_64bit:
desc: Builds Mac OS X 64 bit binaries
desc: Builds Mac OS X x86_64 bit binaries
dir: "{{.DIST_DIR}}"
cmds:
- |
Expand All @@ -212,7 +213,7 @@ tasks:

vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_amd64"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}} -buildvcs=false"
BUILD_PLATFORM: "darwin/amd64"
# We are experiencing the following error with macOS_64bit build:
#
Expand All @@ -227,6 +228,28 @@ tasks:
#
# To compile it we need an SDK >=10.12 so we use the debian10 based container that
# has the SDK 10.14 installed.
CONTAINER_TAG: "{{.GO_VERSION}}-darwin"
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}} -buildvcs=false"
BUILD_PLATFORM: "darwin/arm64"
CONTAINER_TAG: "{{.GO_VERSION}}-darwin-arm64-debian10"
PACKAGE_PLATFORM: "macOS_ARM64"
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
2 changes: 1 addition & 1 deletion gon.config.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/general/gon.config.hcl
# See: https://github.com/Bearer/gon#configuration-file
source = ["dist/arduino-cloud-cli_osx_darwin_amd64/arduino-cloud-cli"]
source = ["dist/arduino-cloud-cli_osx_darwin_amd64/arduino-cloud-cli", "dist/arduino-cloud-cli_osx_darwin_arm64/arduino-cloud-cli"]
bundle_id = "cc.arduino.arduino-cloud-cli"

sign {
Expand Down