#!/bin/sh
# Puts together an archive of the source code and necessary helper files
# for the D&D 4th Ed Encounter Builder.

source_path=`realpath $0`
source_path=`dirname "${source_path}"`
orig_dir=`pwd`
version=`grep -e "__version__" "${source_path}/__init__.py" | sed -n -r -e "s/^.*__version__ = '(.+)'.*$/\\1/ p"`
archive_name=DnD4thEdEncounterBuilder_source_v${version}.zip

echo Building source archive ${archive_name}

cd "${source_path}/.."

zip "${orig_dir}/${archive_name}" \
"DnD4thEdEncounterBuilder/docs" $(find "DnD4thEdEncounterBuilder/docs") \
"DnD4thEdEncounterBuilder/Monster Examples" DnD4thEdEncounterBuilder/Monster\ Examples/* \
"DnD4thEdEncounterBuilder/PyRTF3" DnD4thEdEncounterBuilder/PyRTF3/*.py \
"DnD4thEdEncounterBuilder/sphinx-docs" $(find "DnD4thEdEncounterBuilder/sphinx-docs") \
"DnD4thEdEncounterBuilder/Resources/D&D 4e Icons v3.ttf" "DnD4thEdEncounterBuilder/Resources/EncounterBuilderIcon.ico" "DnD4thEdEncounterBuilder/Resources/EncounterBuilderIcon.png" \
"DnD4thEdEncounterBuilder/Resources/Program Icon - Icon Layers.xcf" "DnD4thEdEncounterBuilder/Resources/Program Icon.xcf" \
"DnD4thEdEncounterBuilder/Resources/pywin32-222.win32-py3.6.exe" "DnD4thEdEncounterBuilder/Resources/Word2007RTFSpec9.doc" \
"DnD4thEdEncounterBuilder/__init__.py" "DnD4thEdEncounterBuilder/encounter_builder.py" "DnD4thEdEncounterBuilder/encounter_ui_helpers.py" "DnD4thEdEncounterBuilder/exporters.py" \
"DnD4thEdEncounterBuilder/file_utils.py" "DnD4thEdEncounterBuilder/jsonviewer.py" "DnD4thEdEncounterBuilder/monster_builder.py" "DnD4thEdEncounterBuilder/monster_ui_helpers.py" \
"DnD4thEdEncounterBuilder/stat_stuff.py" "DnD4thEdEncounterBuilder/ui_helpers.py" \
"DnD4thEdEncounterBuilder/.pylintrc" "DnD4thEdEncounterBuilder/build.ps1" "DnD4thEdEncounterBuilder/EncounterBuilder.spec" "DnD4thEdEncounterBuilder/EncounterBuilderIcon.ico" \
"DnD4thEdEncounterBuilder/Development Notes.txt" "DnD4thEdEncounterBuilder/README.txt" \
"DnD4thEdEncounterBuilder/Test Encounter.enc" "DnD4thEdEncounterBuilder/Test Encounter.rtf" "DnD4thEdEncounterBuilder/Test Minion.mon" "DnD4thEdEncounterBuilder/Test Minion.rtf" \
"DnD4thEdEncounterBuilder/Test Monster.mon" "DnD4thEdEncounterBuilder/Test Monster.rtf" "DnD4thEdEncounterBuilder/Test Swarm.mon" \
"DnD4thEdEncounterBuilder/Testy the Super Minion.mon" "DnD4thEdEncounterBuilder/Testy the Super Minion.rtf" \
"DnD4thEdEncounterBuilder/build_source_archive.sh"

cd "${orig_dir}"

echo Done
