-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build script generated by ChatGPT
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,6 @@ | |
# Go workspace file | ||
go.work | ||
|
||
/out/ | ||
/config.yml | ||
/power |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |