Skip to content

Commit

Permalink
Add release notes gen to cross compiler script
Browse files Browse the repository at this point in the history
  • Loading branch information
benbusby committed Jan 17, 2025
1 parent 083870b commit 0d99384
Showing 1 changed file with 46 additions and 11 deletions.
57 changes: 46 additions & 11 deletions cross_compile.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,76 @@
#!/bin/sh
#!/bin/bash

dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

mkdir -p $dir/out/
rm -rf $dir/out/*
rm -f $dir/out/*

platforms=(
"windows/386"
"windows/amd64"
"windows/arm64"
"darwin/amd64"
"darwin/arm64"
"linux/arm"
"linux/amd64"
"linux/arm64"
"linux/386")
"linux/386"
"darwin/amd64"
"darwin/arm64"
"windows/386"
"windows/amd64"
"windows/arm64")

projects=(
"cli"
"backend")

VER="$(go run ./utils/print_version.go)"
RELEASE_NOTES_FILE="$dir/out/RELEASE_NOTES.txt"
RELEASE_NOTES_LINK="https://github.com/benbusby/yeetfile/releases/download/$VER"

cat >$RELEASE_NOTES_FILE <<EOL
___
Linux, macOS, and Windows binaries for the CLI app and for the server are included below. These archives contain a single executable that you can run on your machine.
EOL

capitalize()
{
printf '%s' "$1" | head -c 1 | tr [:lower:] [:upper:]
printf '%s' "$1" | tail -c '+2'
}

for project in "${projects[@]}"
do
project_name=$project
if [ $project = "cli" ]; then
project_name=$(echo $project_name | tr '[a-z]' '[A-Z]')
else
project_name=$(capitalize $project)
fi

printf -- "### $project_name\n\n" >> $RELEASE_NOTES_FILE
for platform in "${platforms[@]}"
do
echo "Compiling $project for $platform..."
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}

os_name=$(capitalize $GOOS)
arch_name=$GOARCH

if [ $project = "cli" ]; then
output_name="yeetfile"
else
output_name="yeetfile-server"
fi

tar_name="${output_name}_${GOOS}_${GOARCH}_${VER}.tar.gz"
if [ $GOOS = "darwin" ]; then
tar_name="${output_name}_macos_${GOARCH}_${VER}.tar.gz"
os_name="macOS"
elif [ $GOARCH = "arm" ]; then
tar_name="${output_name}-${GOOS}-arm32-${VER}.tar.gz"
arch_name="arm32"
fi

tar_name="${output_name}_${GOOS}_${arch_name}_${VER}.tar.gz"

if [ $GOOS = "windows" ]; then
output_name+=".exe"
fi
Expand All @@ -58,5 +85,13 @@ do

tar -czvf out/$tar_name $output_name
rm -f $output_name

full_link="$RELEASE_NOTES_LINK/$tar_name"

printf -- "- $os_name (\`$arch_name\`): [$tar_name]($full_link)\n" >> $RELEASE_NOTES_FILE
done

printf "\n" >> $RELEASE_NOTES_FILE
done

cat $RELEASE_NOTES_FILE

0 comments on commit 0d99384

Please sign in to comment.