It would be ideal to use WP-CLI's [`dist-archive`](https://github.com/wp-cli/dist-archive-command) command.