release.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. # Create a "bin" directory if it doesn't exist
  3. mkdir -p bin
  4. # List of target operating systems
  5. OS_TARGETS=("windows" "linux" "darwin")
  6. # Corresponding architectures for each OS
  7. ARCH_TARGETS=("386 amd64" "386 amd64 arm arm64" "amd64 arm64")
  8. # Loop through each OS target
  9. for index in "${!OS_TARGETS[@]}"
  10. do
  11. OS=${OS_TARGETS[$index]}
  12. for ARCH in ${ARCH_TARGETS[$index]}
  13. do
  14. # Set the GOOS environment variable for the current target OS
  15. export GOOS="$OS"
  16. export GOARCH="$ARCH"
  17. # Set the output binary name to "ente-cli" for the current OS and architecture
  18. BINARY_NAME="ente-$OS-$ARCH"
  19. # Add .exe extension for Windows
  20. if [ "$OS" == "windows" ]; then
  21. BINARY_NAME="ente-$OS-$ARCH.exe"
  22. fi
  23. # Build the binary and place it in the "bin" directory
  24. go build -o "bin/$BINARY_NAME" main.go
  25. # Print a message indicating the build is complete for the current OS and architecture
  26. echo "Built for $OS ($ARCH) as bin/$BINARY_NAME"
  27. done
  28. done
  29. # Clean up any environment variables
  30. unset GOOS
  31. unset GOARCH
  32. # Print a message indicating the build process is complete
  33. echo "Build process completed for all platforms and architectures. Binaries are in the 'bin' directory."