diff --git a/.DS_Store b/.DS_Store index 82d21b7..cf476aa 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/build.sh b/build.sh index 8e43a41..55483e1 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,24 @@ DEFAULT_ARCH="linux/amd64" # Supported architectures (adjust as needed) -ARCHITECTURES=("linux/amd64" "linux/arm64" "linux/arm/v7") +ARCHITECTURES=("linux/amd64" "linux/arm64" "linux/arm/v7" "darwin/amd64" "darwin/arm64") + +# Ensure all necessary directories exist and go modules are ready +prepare_build() { + # Create necessary directories if they don't exist + mkdir -p dist + mkdir -p build_logs + + # Initialize go modules if go.mod does not exist + if [ ! -f go.mod ]; then + echo "Initializing Go modules" + go mod init go-glitch + fi + + # Fetch and ensure all dependencies are up to date + echo "Checking dependencies..." + go mod tidy +} # Build function build_binary() { @@ -16,14 +33,38 @@ build_binary() { output_name="${output_name}_${os}_${arch}" fi - echo "Building for ${os}/${arch} -> ${output_name}" - GOOS=${os} GOARCH=${arch} go build -o ${output_name} + output_name="dist/${output_name}" + + # Dynamic Linking + echo "Building dynamically linked for ${os}/${arch} -> ${output_name}" + GOOS=${os} GOARCH=${arch} go build -o ${output_name} main.go 2>build_logs/${os}_${arch}_build.log + if [ $? -eq 0 ]; then + echo "Successfully built ${output_name}" + else + echo "Failed to build ${output_name}. Check build_logs/${os}_${arch}_build.log for errors." + fi + + # Static Linking + if [[ "$os" == "linux" ]]; then # Typically, static linking is most relevant for Linux environments + static_output_name="${output_name}_static" + echo "Building statically linked for ${os}/${arch} -> ${static_output_name}" + CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build -a -ldflags '-extldflags "-static"' -o ${static_output_name} main.go 2>build_logs/${os}_${arch}_static_build.log + if [ $? -eq 0 ]; then + echo "Successfully built ${static_output_name}" + else + echo "Failed to build ${static_output_name}. Check build_logs/${os}_${arch}_static_build.log for errors." + fi + fi } # Main Build Process +prepare_build for arch in "${ARCHITECTURES[@]}"; do - IFS='/' read -r -a parts <<< "$arch" # Split architecture string + IFS='/' read -r -a parts <<< "$arch" # Split architecture string os=${parts[0]} arch=${parts[1]} - build_binary $os $arch + build_binary $os $arch done + +echo "Build process completed." + diff --git a/build_logs/darwin_amd64_build.log b/build_logs/darwin_amd64_build.log new file mode 100644 index 0000000..e69de29 diff --git a/build_logs/darwin_arm64_build.log b/build_logs/darwin_arm64_build.log new file mode 100644 index 0000000..e69de29 diff --git a/build_logs/linux_amd64_build.log b/build_logs/linux_amd64_build.log new file mode 100644 index 0000000..e69de29 diff --git a/build_logs/linux_amd64_static_build.log b/build_logs/linux_amd64_static_build.log new file mode 100644 index 0000000..e69de29 diff --git a/build_logs/linux_arm64_build.log b/build_logs/linux_arm64_build.log new file mode 100644 index 0000000..e69de29 diff --git a/build_logs/linux_arm64_static_build.log b/build_logs/linux_arm64_static_build.log new file mode 100644 index 0000000..e69de29 diff --git a/build_logs/linux_arm_build.log b/build_logs/linux_arm_build.log new file mode 100644 index 0000000..e69de29 diff --git a/build_logs/linux_arm_static_build.log b/build_logs/linux_arm_static_build.log new file mode 100644 index 0000000..e69de29 diff --git a/go-glitch b/dist/go-glitch similarity index 83% rename from go-glitch rename to dist/go-glitch index 8e10dbf..fd48523 100755 Binary files a/go-glitch and b/dist/go-glitch differ diff --git a/dist/go-glitch_darwin_amd64 b/dist/go-glitch_darwin_amd64 new file mode 100755 index 0000000..e88194c Binary files /dev/null and b/dist/go-glitch_darwin_amd64 differ diff --git a/dist/go-glitch_darwin_arm64 b/dist/go-glitch_darwin_arm64 new file mode 100755 index 0000000..1197b22 Binary files /dev/null and b/dist/go-glitch_darwin_arm64 differ diff --git a/go-glitch_linux_arm b/dist/go-glitch_linux_arm similarity index 85% rename from go-glitch_linux_arm rename to dist/go-glitch_linux_arm index 06b02c7..ce5d1a1 100755 Binary files a/go-glitch_linux_arm and b/dist/go-glitch_linux_arm differ diff --git a/go-glitch_linux_arm64 b/dist/go-glitch_linux_arm64 similarity index 82% rename from go-glitch_linux_arm64 rename to dist/go-glitch_linux_arm64 index 511b1fd..8edb862 100755 Binary files a/go-glitch_linux_arm64 and b/dist/go-glitch_linux_arm64 differ diff --git a/dist/go-glitch_linux_arm64_static b/dist/go-glitch_linux_arm64_static new file mode 100755 index 0000000..631d65d Binary files /dev/null and b/dist/go-glitch_linux_arm64_static differ diff --git a/dist/go-glitch_linux_arm_static b/dist/go-glitch_linux_arm_static new file mode 100755 index 0000000..81113d0 Binary files /dev/null and b/dist/go-glitch_linux_arm_static differ diff --git a/dist/go-glitch_static b/dist/go-glitch_static new file mode 100755 index 0000000..ce3337b Binary files /dev/null and b/dist/go-glitch_static differ diff --git a/go.mod b/go.mod index 7036b78..2af2912 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,9 @@ module go-glitch go 1.21.1 +require github.com/getsentry/sentry-go v0.27.0 + require ( - github.com/getsentry/sentry-go v0.27.0 // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect ) diff --git a/go.sum b/go.sum index 121a9cb..b3daf4a 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,22 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..3f67e46 --- /dev/null +++ b/install.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +INSTALL_DIR="/usr/local/bin" +BINARY_NAME="go-glitch" +BASE_URL="https://git.nixc.us/Nixius/go-glitch/raw/branch/main/dist" + +declare -A binaries +binaries["linux/amd64"]="go-glitch_linux_amd64" +binaries["linux/arm64"]="go-glitch_linux_arm64" +binaries["linux/arm/v7"]="go-glitch_linux_arm" +binaries["darwin/amd64"]="go-glitch_darwin_amd64" +binaries["darwin/arm64"]="go-glitch_darwin_arm64" + +OS="$(uname -s | tr '[:upper:]' '[:lower:]')" +ARCH="$(uname -m)" + +case $ARCH in + x86_64) ARCH="amd64" ;; + arm64 | aarch64) ARCH="arm64" ;; + arm*) ARCH="arm/v7" ;; + *) echo "Unsupported architecture: $ARCH"; exit 1 ;; +esac + +KEY="${OS}/${ARCH}" + +if [[ -z "${binaries[$KEY]}" ]]; then + echo "No pre-built binary for your system architecture ($KEY)." + exit 1 +fi + +BINARY_URL="${BASE_URL}/${binaries[$KEY]}" + +echo "Downloading and installing $BINARY_NAME from $BINARY_URL..." +sudo curl -sSL "$BINARY_URL" -o "${INSTALL_DIR}/${BINARY_NAME}" + +sudo chmod +x "${INSTALL_DIR}/${BINARY_NAME}" +echo "Installed $BINARY_NAME to $INSTALL_DIR" diff --git a/go-glitch.go b/main.go similarity index 100% rename from go-glitch.go rename to main.go