How is the Stan release tarball created?

How is the Stan release tarball (e.g., https://github.com/stan-dev/stan/archive/v2.20.0.tar.gz) created? Is there some git magic to include the contents of the subrepositories?

I believe the source archives for releases are built by GitHub directly when you create a release. @seantalts might be the person to ask for more details.

We use these scripts: https://github.com/stan-dev/ci-scripts/tree/master/release-scripts

short answer: git-archive-all I think.