From 842453bc91ac8c87e888c8b0783bd8c11a241352 Mon Sep 17 00:00:00 2001 From: Lukas Wingerberg Date: Sun, 17 Dec 2023 11:56:26 +0100 Subject: [PATCH] build multiarch --- .woodpecker/build_go_release.yaml | 11 +++++++++++ build.sh | 23 +++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.woodpecker/build_go_release.yaml b/.woodpecker/build_go_release.yaml index 74e6ad7..93b3536 100644 --- a/.woodpecker/build_go_release.yaml +++ b/.woodpecker/build_go_release.yaml @@ -6,3 +6,14 @@ steps: when: branch: ${CI_REPO_DEFAULT_BRANCH} event: push + release: + image: woodpeckerci/plugin-github-release + settings: + files: + - out/verify_pw* + title: ${CI_COMMIT_TAG##v} + api-key: + from_secret: github_token + when: + branch: ${CI_REPO_DEFAULT_BRANCH} + event: tag \ No newline at end of file diff --git a/build.sh b/build.sh index b866bc3..9088b38 100755 --- a/build.sh +++ b/build.sh @@ -9,21 +9,24 @@ BINARY_NAME="verify_pw" # Set the platform and architecture PLATFORM="linux" -ARCHITECTURE="amd64" +ARCHITECTURES=("amd64" "386" "arm64" "arm") # Enable Go Modules export GO111MODULE=on mkdir ./out -env GOOS=$PLATFORM GOARCH=$ARCHITECTURE go mod tidy +for ARCH in "${ARCHITECTURES[@]}" +do + env GOOS=${PLATFORM} GOARCH="${ARCH}" go mod tidy + # Build the binary + env GOOS=${PLATFORM} GOARCH="${ARCH}" go build -o "./out/${BINARY_NAME}_${ARCH}" ${SCRIPT_NAME} + # Check if the build was successful + if [ $? -eq 0 ]; then + echo "Build successful! The binary is named '${BINARY_NAME}_${ARCH}' in the ./out directory" + else + echo "Build failed!" + fi +done -# Build the binary -env GOOS=$PLATFORM GOARCH=$ARCHITECTURE go build -o ./out/$BINARY_NAME $SCRIPT_NAME -# Check if the build was successful -if [ $? -eq 0 ]; then - echo "Build successful! The binary is named '$BINARY_NAME'" -else - echo "Build failed!" -fi