Add the release packaging scripts to build.sh

This keeps the same release flow of Jenkins assembling tested artifacts into
the final release package, and just moves the scripts for doing so into
build.sh so that changes to the release packaging can be done via PRs. It also
adds a test target which mimics the CI setup's assembly flow (but not any of
the actual releasing parts) so that changes to the release tasks can be tested
locally.
Update the release scripts for the new examples packaging
Change uses of xcpretty to forward $XCMODE instead
Add package-test-examples task
Fix docs packaging in test script
Merge pull request #911 from realm/tg-build-packaging

Add the release packaging scripts to build.sh