build-all 984 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # The basename of our binary
  3. BASE="rss2hook"
  4. # Get the dependencies
  5. go get -t -v -d $(go list ./...)
  6. #
  7. # We build on only a single platform/arch: CGO is hard
  8. #
  9. BUILD_PLATFORMS="linux"
  10. BUILD_ARCHS="amd64"
  11. # For each platform
  12. for OS in ${BUILD_PLATFORMS[@]}; do
  13. # For each arch
  14. for ARCH in ${BUILD_ARCHS[@]}; do
  15. # Setup a suffix for the binary
  16. SUFFIX="${OS}"
  17. # i386 is better than 386
  18. if [ "$ARCH" = "386" ]; then
  19. SUFFIX="${SUFFIX}-i386"
  20. else
  21. SUFFIX="${SUFFIX}-${ARCH}"
  22. fi
  23. # Windows binaries should end in .EXE
  24. if [ "$OS" = "windows" ]; then
  25. SUFFIX="${SUFFIX}.exe"
  26. fi
  27. echo "Building for ${OS} [${ARCH}] -> ${BASE}-${SUFFIX}"
  28. # Run the build
  29. export GOARCH=${ARCH}
  30. export GOOS=${OS}
  31. export CGO_ENABLED=1
  32. go build -ldflags "-X main.version=$(git describe --tags)" -o "${BASE}-${SUFFIX}"
  33. done
  34. done