#!/bin/bash

# Check which branch we're on to make sure we're not distributing non demo versions.
git_vers=$(git symbolic-ref --short -q HEAD)
expected_git_vers="main"

if [ $git_vers != $expected_git_vers ]; then
    echo "----------------------------------------------------------------------------"
    echo "WARNING: Not on expected git branch" $expected_git_vers", on" $git_vers
    echo "----------------------------------------------------------------------------"
fi

if [ "$1" == "" ]; then
    echo "ERROR: No build target specified."
    exit
else
    echo "Building for $1"
fi
# Set target.
export BUILD_TARGET="$1"

echo "Building..."

if pyinstaller oprattle.general.spec --noconfirm; then
    # Create master archive.
    rm -R ../build
    echo "Creating archive..."
    cd dist
    name=$(ls -d openprattle.*)
    tar -czf "$name.tar.gz" "$name"

fi

