Skip to content

Commit

Permalink
Update build-and-upload-binaries.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
bearaujus committed Dec 7, 2024
1 parent fae5907 commit 77646ee
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build-and-upload-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install build tools for cgo
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ libc6-dev gcc-multilib g++-x86-64-linux-gnu libc6-dev-amd64-cross
sudo apt-get install -y gcc g++ libc6-dev gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf
# Get the version from the tag
- name: Get version from tag
Expand Down Expand Up @@ -55,39 +55,39 @@ jobs:
"darwin/amd64"
"darwin/arm64"
)
VERSION=${{ env.VERSION }}
REPO_NAME=${{ env.REPO_NAME }}
# Create a directory for the build outputs
mkdir -p binaries
# Loop through the GOOS and GOARCH combinations and build binaries
for GOOS_ARCH in "${GOOS_ARCH_LIST[@]}"; do
GOOS=$(echo $GOOS_ARCH | cut -d'/' -f1)
GOARCH=$(echo $GOOS_ARCH | cut -d'/' -f2)
# Disable cgo for windows builds (or other platforms that don't need cgo)
if [[ "$GOOS" == "windows" ]]; then
# Disable cgo for ARM builds
if [[ "$GOARCH" == "arm" || "$GOARCH" == "arm64" || "$GOOS" == "windows" ]]; then
export CGO_ENABLED=0
else
export CGO_ENABLED=1
fi
# Skip problematic platforms if necessary (e.g., AIX or others)
if [[ "$GOOS" == "aix" && "$GOARCH" == "ppc64" ]]; then
echo "Skipping aix/ppc64 due to unsupported platform"
continue
fi
# Set environment variables
export GOOS
export GOARCH
# Build the binary with the required format and ldflags for version, name, arch, and goos
FILENAME="${REPO_NAME}-${VERSION}-${GOOS}-${GOARCH}"
go build -ldflags "-X main.name=${REPO_NAME} -X main.version=${VERSION} -X main.arch=${GOARCH} -X main.goos=${GOOS}" -o "binaries/${FILENAME}"
echo "Built binary: ${FILENAME}"
done
Expand Down

0 comments on commit 77646ee

Please sign in to comment.