Skip to content

Commit

Permalink
Add build script generated by ChatGPT
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4cks committed Dec 2, 2023
1 parent 84cd5a2 commit ca9f6e5
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
# Go workspace file
go.work

/out/
/config.yml
/power
50 changes: 50 additions & 0 deletions build_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Script generated by ChatGPT

# Output directory
output_dir="out"

# Operating system
os="linux"

# List of architectures
architectures=("386" "amd64" "arm64" "armv6" "armv7")

# Checksums file name
checksums_file="$output_dir/checksums.txt"

# Remove the output directory if it already exists
rm -rf "$output_dir"

# Create the output directory
mkdir -p "$output_dir"

# Loop over architectures
for arch in "${architectures[@]}"; do
# Binary name
binary_name="power-linux-$arch"

# Full path of the binary
binary_path="$output_dir/$binary_name"

# Use go build to generate the binary
if [ "$arch" == "armv6" ] || [ "$arch" == "armv7" ]; then
GOOS=$os GOARCH=arm GOARM=$(if [ "$arch" == "armv6" ]; then echo 6; else echo 7; fi) go build -o "$binary_path"
else
GOOS=$os GOARCH=$arch go build -o "$binary_path"
fi

# Display a message indicating that the binary is built
echo "Binary $binary_name built successfully."

# Calculate the SHA256 checksum
checksum=$(sha256sum "$binary_path" | cut -d ' ' -f 1)

# Add the checksum to the checksums.txt file
echo "$checksum *$binary_name" >> "$checksums_file"
done

# Display a message indicating that the process is complete
echo "Binaries successfully generated in the $output_dir directory."
echo "Checksums saved in the $checksums_file file."

0 comments on commit ca9f6e5

Please sign in to comment.