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

Build binary for linux/arm64 #358

Merged
merged 1 commit into from
Dec 4, 2023
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
5 changes: 3 additions & 2 deletions .github/workflows/update-gardenctl-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Upload binaries to release
uses: AButler/upload-release-assets@c94805dc72e4b20745f543da0f62eaee7722df7a # pin@v2.0.2
with:
files: 'bin/darwin-amd64/gardenctl_v2_darwin_amd64;bin/darwin-arm64/gardenctl_v2_darwin_arm64;bin/linux-amd64/gardenctl_v2_linux_amd64;bin/windows-amd64/gardenctl_v2_windows_amd64.exe'
files: 'bin/darwin-amd64/gardenctl_v2_darwin_amd64;bin/darwin-arm64/gardenctl_v2_darwin_arm64;bin/linux-amd64/gardenctl_v2_linux_amd64;bin/linux-arm64/gardenctl_v2_linux_arm64;bin/windows-amd64/gardenctl_v2_windows_amd64.exe'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ env.latest_release_filtered_tag }}
- name: Get token for gardener-github-pkg-mngr app
Expand All @@ -39,7 +39,8 @@ jobs:
darwin_sha256sum_amd64=$(sha256sum bin/darwin-amd64/gardenctl_v2_darwin_amd64 | awk '{print $1}')
darwin_sha256sum_arm64=$(sha256sum bin/darwin-arm64/gardenctl_v2_darwin_arm64 | awk '{print $1}')
linux_sha256sum_amd64=$(sha256sum bin/linux-amd64/gardenctl_v2_linux_amd64 | awk '{print $1}')
data='{"event_type": "update", "client_payload": { "component": "gardenctl-v2", "tag": "'"$latest_release_filtered_tag"'", "darwin_sha_amd64": "'"$darwin_sha256sum_amd64"'", "darwin_sha_arm64": "'"$darwin_sha256sum_arm64"'", "linux_sha_amd64": "'"$linux_sha256sum_amd64"'"}}'
linux_sha256sum_arm64=$(sha256sum bin/linux-arm64/gardenctl_v2_linux_arm64 | awk '{print $1}')
data='{"event_type": "update", "client_payload": { "component": "gardenctl-v2", "tag": "'"$latest_release_filtered_tag"'", "darwin_sha_amd64": "'"$darwin_sha256sum_amd64"'", "darwin_sha_arm64": "'"$darwin_sha256sum_arm64"'", "linux_sha_amd64": "'"$linux_sha256sum_amd64"'", "linux_sha_arm64": "'"$linux_sha256sum_arm64"'"}}'
echo "${data}"
curl -X POST https://api.github.com/repos/${{ github.repository_owner }}/homebrew-tap/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ generate-sequential: gen-markdown $(MOCKGEN) ## Run go generate
##@ Build

.PHONY: build
build: build-darwin-amd64 build-darwin-arm64 build-linux-amd64 build-windows-amd64 ## Build gardenctl binary for darwin, linux and windows.
build: build-darwin-amd64 build-darwin-arm64 build-linux-amd64 build-linux-arm64 build-windows-amd64 ## Build gardenctl binary for darwin, linux and windows.

.PHONY: build-linux-amd64
build-linux-amd64: ## Build gardenctl binary for linux.
build-linux-amd64: ## Build gardenctl binary for Linux on Intel processors.
@./hack/build-linux-amd64.sh

.PHONY: build-linux-arm64
build-linux-arm64: ## Build gardenctl binary for Linux on ARM processors.
@./hack/build-linux-arm64.sh

.PHONY: build-darwin-amd64
build-darwin-amd64: ## Build gardenctl binary for darwin on Intel processors.
@./hack/build-darwin-amd64.sh
Expand All @@ -84,5 +88,5 @@ build-darwin-arm64: ## Build gardenctl binary for darwin on Apple Silicon proces
@./hack/build-darwin-arm64.sh

.PHONY: build-windows-amd64
build-windows-amd64: ## Build gardenctl binary for windows.
build-windows-amd64: ## Build gardenctl binary for Windows on Intel processors.
@./hack/build-windows-amd64.sh
28 changes: 4 additions & 24 deletions hack/build-darwin-amd64.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2021 SAP SE or an SAP affiliate company and Gardener contributors
# SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

set -e

# For the build step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
# BINARY_PATH - path to an existing (empty) directory to place build results into.

if [[ -z "${MAIN_REPO_DIR}" ]]; then
export MAIN_REPO_DIR="$(readlink -f $(dirname ${0})/..)"
else
export MAIN_REPO_DIR="$(readlink -f "${MAIN_REPO_DIR}")"
fi

if [[ -z "${BINARY_PATH}" ]]; then
export BINARY_PATH="${MAIN_REPO_DIR}/bin"
else
export BINARY_PATH="$(readlink -f "${BINARY_PATH}")"
fi

pushd "${MAIN_REPO_DIR}" > /dev/null

if [[ -z "${LD_FLAGS}" ]]; then
export LD_FLAGS=$(./hack/get-build-ld-flags.sh)
fi
###############################################################################

out_file="${BINARY_PATH}"/darwin-amd64/gardenctl_v2_darwin_amd64

echo "building for darwin-amd64: ${out_file}"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 GO111MODULE=on go build \
-ldflags "${LD_FLAGS}" \
-o "${out_file}" main.go
export GOOS=darwin
export GOARCH=amd64

popd > /dev/null
${MAIN_REPO_DIR}/hack/build.sh
26 changes: 3 additions & 23 deletions hack/build-darwin-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,16 @@
#
# SPDX-License-Identifier: Apache-2.0

set -e

# For the build step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
# BINARY_PATH - path to an existing (empty) directory to place build results into.

if [[ -z "${MAIN_REPO_DIR}" ]]; then
export MAIN_REPO_DIR="$(readlink -f $(dirname ${0})/..)"
else
export MAIN_REPO_DIR="$(readlink -f "${MAIN_REPO_DIR}")"
fi

if [[ -z "${BINARY_PATH}" ]]; then
export BINARY_PATH="${MAIN_REPO_DIR}/bin"
else
export BINARY_PATH="$(readlink -f "${BINARY_PATH}")"
fi

pushd "${MAIN_REPO_DIR}" > /dev/null

if [[ -z "${LD_FLAGS}" ]]; then
export LD_FLAGS=$(./hack/get-build-ld-flags.sh)
fi
###############################################################################

out_file="${BINARY_PATH}"/darwin-arm64/gardenctl_v2_darwin_arm64

echo "building for darwin-arm64: ${out_file}"
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 GO111MODULE=on go build \
-ldflags "${LD_FLAGS}" \
-o "${out_file}" main.go
export GOOS=darwin
export GOARCH=arm64

popd > /dev/null
${MAIN_REPO_DIR}/hack/build.sh
28 changes: 4 additions & 24 deletions hack/build-linux-amd64.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2021 SAP SE or an SAP affiliate company and Gardener contributors
# SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

set -e

# For the build step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
# BINARY_PATH - path to an existing (empty) directory to place build results into.

if [[ -z "${MAIN_REPO_DIR}" ]]; then
export MAIN_REPO_DIR="$(readlink -f $(dirname ${0})/..)"
else
export MAIN_REPO_DIR="$(readlink -f "${MAIN_REPO_DIR}")"
fi

if [[ -z "${BINARY_PATH}" ]]; then
export BINARY_PATH="${MAIN_REPO_DIR}/bin"
else
export BINARY_PATH="$(readlink -f "${BINARY_PATH}")"
fi

pushd "${MAIN_REPO_DIR}" > /dev/null

if [[ -z "${LD_FLAGS}" ]]; then
export LD_FLAGS=$(./hack/get-build-ld-flags.sh)
fi
###############################################################################

out_file="${BINARY_PATH}"/linux-amd64/gardenctl_v2_linux_amd64

echo "building for linux-amd64: ${out_file}"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build \
-ldflags "${LD_FLAGS}" \
-o "${out_file}" main.go
export GOOS=linux
export GOARCH=amd64

popd > /dev/null
${MAIN_REPO_DIR}/hack/build.sh
19 changes: 19 additions & 0 deletions hack/build-linux-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

# For the build step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.

if [[ -z "${MAIN_REPO_DIR}" ]]; then
export MAIN_REPO_DIR="$(readlink -f $(dirname ${0})/..)"
else
export MAIN_REPO_DIR="$(readlink -f "${MAIN_REPO_DIR}")"
fi

export GOOS=linux
export GOARCH=arm64

${MAIN_REPO_DIR}/hack/build.sh
28 changes: 4 additions & 24 deletions hack/build-windows-amd64.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2021 SAP SE or an SAP affiliate company and Gardener contributors
# SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

set -e

# For the build step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
# BINARY_PATH - path to an existing (empty) directory to place build results into.

if [[ -z "${MAIN_REPO_DIR}" ]]; then
export MAIN_REPO_DIR="$(readlink -f $(dirname ${0})/..)"
else
export MAIN_REPO_DIR="$(readlink -f "${MAIN_REPO_DIR}")"
fi

if [[ -z "${BINARY_PATH}" ]]; then
export BINARY_PATH="${MAIN_REPO_DIR}/bin"
else
export BINARY_PATH="$(readlink -f "${BINARY_PATH}")"
fi

pushd "${MAIN_REPO_DIR}" > /dev/null

if [[ -z "${LD_FLAGS}" ]]; then
export LD_FLAGS=$(./hack/get-build-ld-flags.sh)
fi
###############################################################################

out_file="${BINARY_PATH}"/windows-amd64/gardenctl_v2_windows_amd64.exe

echo "building for windows-amd64: ${out_file}"
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 GO111MODULE=on go build \
-ldflags "${LD_FLAGS}" \
-o "${out_file}" main.go
export GOOS=windows
export GOARCH=amd64

popd > /dev/null
${MAIN_REPO_DIR}/hack/build.sh
39 changes: 39 additions & 0 deletions hack/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

set -e

# For the build step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
# BINARY_PATH - path to an existing (empty) directory to place build results into.

if [[ -z "${MAIN_REPO_DIR}" ]]; then
export MAIN_REPO_DIR="$(readlink -f $(dirname ${0})/..)"
else
export MAIN_REPO_DIR="$(readlink -f "${MAIN_REPO_DIR}")"
fi

if [[ -z "${BINARY_PATH}" ]]; then
export BINARY_PATH="${MAIN_REPO_DIR}/bin"
else
export BINARY_PATH="$(readlink -f "${BINARY_PATH}")"
fi

pushd "${MAIN_REPO_DIR}" > /dev/null

if [[ -z "${LD_FLAGS}" ]]; then
export LD_FLAGS=$("${MAIN_REPO_DIR}/hack/get-build-ld-flags.sh")
fi
###############################################################################

out_file="${BINARY_PATH}/${GOOS}-${GOARCH}/gardenctl_v2_${GOOS}_${GOARCH}"

echo "building for ${GOOS}-${GOARCH}: ${out_file}"
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GO111MODULE=on go build \
-ldflags "${LD_FLAGS}" \
-o "${out_file}" main.go

popd > /dev/null