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

Updated DistTask.yml / Add support for macos_ARM64 builds #77

Merged
merged 1 commit into from
Feb 21, 2024
Merged
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
83 changes: 48 additions & 35 deletions DistTasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ version: "3"

vars:
CONTAINER: "docker.elastic.co/beats-dev/golang-crossbuild"
GO_VERSION: "1.18.5"
GO_VERSION: "1.21.6"
CHECKSUM_FILE: "{{.VERSION}}-checksums.txt"

tasks:
Expand All @@ -34,21 +34,20 @@ tasks:
- task: Linux_ARMv7
- task: Linux_ARM64
- task: macOS_64bit
- task: macOS_ARM64

Windows_32bit:
desc: Builds Windows 32 bit binaries
dir: "{{.DIST_DIR}}"
cmds:
- |
mkdir {{.PLATFORM_DIR}}
cp ../LICENSE.txt {{.PLATFORM_DIR}}/
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"

zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe {{.PLATFORM_DIR}}/LICENSE.txt
zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}

vars:
Expand All @@ -64,15 +63,13 @@ tasks:
dir: "{{.DIST_DIR}}"
cmds:
- |
mkdir {{.PLATFORM_DIR}}
cp ../LICENSE.txt {{.PLATFORM_DIR}}/
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"

zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe {{.PLATFORM_DIR}}/LICENSE.txt
zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}

vars:
Expand All @@ -88,15 +85,13 @@ tasks:
dir: "{{.DIST_DIR}}"
cmds:
- |
mkdir {{.PLATFORM_DIR}}
cp ../LICENSE.txt {{.PLATFORM_DIR}}/
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"

tar cz {{.PLATFORM_DIR}} -f {{.PACKAGE_NAME}}
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}

vars:
Expand All @@ -112,15 +107,13 @@ tasks:
dir: "{{.DIST_DIR}}"
cmds:
- |
mkdir {{.PLATFORM_DIR}}
cp ../LICENSE.txt {{.PLATFORM_DIR}}/
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"

tar cz {{.PLATFORM_DIR}} -f {{.PACKAGE_NAME}}
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}

vars:
Expand All @@ -136,15 +129,13 @@ tasks:
dir: "{{.DIST_DIR}}"
cmds:
- |
mkdir {{.PLATFORM_DIR}}
cp ../LICENSE.txt {{.PLATFORM_DIR}}/
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"

tar cz {{.PLATFORM_DIR}} -f {{.PACKAGE_NAME}}
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}

vars:
Expand All @@ -160,15 +151,13 @@ tasks:
dir: "{{.DIST_DIR}}"
cmds:
- |
mkdir {{.PLATFORM_DIR}}
cp ../LICENSE.txt {{.PLATFORM_DIR}}/
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"

tar cz {{.PLATFORM_DIR}} -f {{.PACKAGE_NAME}}
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}

vars:
Expand Down Expand Up @@ -203,7 +192,11 @@ tasks:
#
# Until there is a fix released we must use a recent gcc for Linux_ARMv6 build, so for this
# build we select the debian10 based container.
CONTAINER_TAG: "{{.GO_VERSION}}-armel-debian10"
#
# BTW:
# - debian10 is not available
# - since we do not use CGO this time, we revert to the old debian9 based container.
CONTAINER_TAG: "{{.GO_VERSION}}-armel-debian9"
PACKAGE_PLATFORM: "Linux_ARMv6"
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

Expand All @@ -212,15 +205,13 @@ tasks:
dir: "{{.DIST_DIR}}"
cmds:
- |
mkdir {{.PLATFORM_DIR}}
cp ../LICENSE.txt {{.PLATFORM_DIR}}/
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"

tar cz {{.PLATFORM_DIR}} -f {{.PACKAGE_NAME}}
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}

vars:
Expand All @@ -235,16 +226,15 @@ tasks:
desc: Builds Mac OS X 64 bit binaries
dir: "{{.DIST_DIR}}"
cmds:
# "git config safe.directory" is required until this is fixed https://github.com/elastic/golang-crossbuild/issues/232
- |
mkdir {{.PLATFORM_DIR}}
cp ../LICENSE.txt {{.PLATFORM_DIR}}/
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
--build-cmd "git config --global --add safe.directory /home/build && {{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"

tar cz {{.PLATFORM_DIR}} -f {{.PACKAGE_NAME}}
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}

vars:
Expand All @@ -267,3 +257,26 @@ 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:
# "git config safe.directory" is required until this is fixed https://github.com/elastic/golang-crossbuild/issues/232
- |
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=0 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "git config --global --add safe.directory /home/build && {{.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"
Loading