#!/usr/bin/env bash

VERSION=$(cargo get package.version)
mkdir -p dist

echo "Compiling native executable..."
cargo build --release --package hamcty --example search_cty
echo
echo "Packaging native executable..."
pushd target/release/examples > /dev/null || exit
cp -ru ../../../test_data . || exit
tar -czf ../../../dist/hamcty_"${VERSION}"_Linux_amd64.tgz search_cty test_data
popd > /dev/null || exit

echo
echo "Crosscompiling for Windows..."
cargo build --release --target x86_64-pc-windows-gnu --package hamcty --example search_cty
echo
echo "Packaging Windows executable..."
zip -j dist/hamcty_"${VERSION}"_Windows_amd64.zip target/x86_64-pc-windows-gnu/release/examples/search_cty.exe
zip dist/hamcty_"${VERSION}"_Windows_amd64.zip test_data/*

echo
echo "..done!"