Skip to content

Commit

Permalink
build multiarch
Browse files Browse the repository at this point in the history
  • Loading branch information
psych0d0g committed Dec 17, 2023
1 parent 80b737e commit 842453b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .woodpecker/build_go_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 13 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 842453b

Please sign in to comment.