diff --git a/DistTasks.yml b/DistTasks.yml index f75d1d1..07a135c 100644 --- a/DistTasks.yml +++ b/DistTasks.yml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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" @@ -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: @@ -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: @@ -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"