if [[ $TARGET == *"windows"* ]]; then
  ext="zip"
  cmd="zip -r"
else
  ext="tar.gz"
  cmd="tar czf"
fi

name="$PROJECT_NAME-$RELEASE_TAG-$TARGET"
mkdir -p "staging/$name"
files=("$EXE_PATH" README.adoc LICENSE)
for file in "${files[@]}"; do
  [ -f "$file" ] && cp "$file" "staging/$name"
done

# Man page + completions (generated by the generate-extras job).
if [ -d extras ]; then
  [ -f extras/enprot.1 ] && cp extras/enprot.1 "staging/$name"
  if [ -d extras/completions ]; then
    mkdir -p "staging/$name/completions"
    cp extras/completions/* "staging/$name/completions/"
  fi
fi

mkdir -p archives
outname="$PWD/archives/$name.$ext"
pushd staging
$cmd "$outname" "$name"
popd
