How does Drupal.org's packaging script works? Is Drupal.org's packaging script publicly accessible? How does it works? What tools does it use to fetch a module and package it as a tarball? What are the best practices in building a nightly builds for Drupal modules?
The projects on drupal.org are managed by the Project project, which also contains the scripts for this. Some drupal.org specific code (for example the zip. and tar.gz packaging implementations) are also in the Drupal.org customizations project.