# /bin/sh

# Create a dist version of the system
cd ../

# Update license before pack
go-licenses report imuslab.com/zoraxy > system/gomod-license.csv

# Build release distribution
make

# Create and prepare for a Github release style folder structure
rm -rf ./build/github/src
mkdir ./build/github
mkdir ./build/github/src

# Extract the web.tar.gz to src folder
tar -xvf ./dist/web.tar.gz -C ./build/github/src

# Copy the mod folder and all root go files
cp -r ./mod ./build/github/src
cp -r ./web ./build/github/src
cp ./*.go ./build/github/src


# Copy other important files
cp Makefile ./build/github/src
cp start.sh ./build/github/src
cp go.mod ./build/github/src
cp go.sum ./build/github/src


# Generate the doc folder for important docs
cp README.md ./build/github/src

# Back to the build folder
cd ./build

echo "Github Release Structure Created"