#             Magical Torbutton Release Process Incantations
#
#   "May this part of my job one day be replaced by a small shell script"
#

#. Decide the version number.

   export VERSION="1.5.2"
   vim ./src/install.rdf # edit <em:version> tag to reflect version

#. Test upgrades of candidate XPI in latest Firefox and TBB product matrix

   # TODO: Currently manual

#. Generate changelog from git shortlog

   # TODO: Currently manual

#. tx noise: https://svn.torproject.org/svn/translation/trunk/documentation/howto.txt

   cd torbutton.git/trans_tools/po
   torsocks svn up
   torsocks tx pull -a
   cd ..
   ./validate_all.sh | less

   torsocks ./new_tb_strings.sh

   ./mkmoz.sh
   ./mvmoz.sh
   cd ..
   git diff .
   git commit .

#. Tag the release:

   git tag -u mikeperry@fscked.org -s ${VERSION}
   torsocks git push origin-push --tags

#. Create the .xpi

   cd /tmp/
   torsocks git clone git://git.torproject.org/git/torbutton.git torbutton-release
   cd torbutton-release
   git tag -v ${VERSION}   # verify signature against git protocol haaAAXXXX
   git checkout -b tag-${VERSION} ${VERSION}
   mkdir ./pkg
   sh makexpi.sh

#. SHA1 + Sign the .xpi

   gpg -abs ./pkg/torbutton-${VERSION}.xpi
   sha1sum ./pkg/torbutton-${VERSION}.xpi

#. Upload .xpi to website

   chmod 664 ./pkg/torbutton-${VERSION}.xpi*
   torsocks scp ./pkg/torbutton-${VERSION}.xpi* vescum:/srv/www-master.torproject.org/htdocs/dist/torbutton/
   torsocks scp ./pkg/torbutton-${VERSION}.xpi vescum:/srv/www-master.torproject.org/htdocs/dist/torbutton/torbutton-current.xpi
   torsocks scp ./pkg/torbutton-${VERSION}.xpi.asc vescum:/srv/www-master.torproject.org/htdocs/dist/torbutton/torbutton-current.xpi.asc

#. Update update-unsigned.rdf in torbutton.git with package sha1

   cd torbutton.git
   vim update-unsigned.rdf   # Add <li> and <description> w/ sha1 and version

#. Sign the new update-unsigned.rdf.

   # Key creation based on these instructions:
   # Command line: http://blog.techno-barje.fr/post/2009/10/08/How-to-setup-a-mozilla-extension-update-server/
   # Gui: https://www.binaryturf.com/steps-release-extension-firefox-3/

   # TODO: Process currently manual due to offline signing.
   # No need to fear the reaper, man. We can do online signing if we just put
   # our minds to it: https://trac.torproject.org/projects/tor/ticket/6011

   # Special note: I was unable to update an already signed
   # copy of the update.rdf for a new release. We probably need to 
   # keep the unsigned version around as input? See the root directory 
   # of the torbutton.git for a copy.
   ./mccoy-cli.x86/mccoy -profile ./.mozilla/mccoy/*.default/ -signRDF update-unsigned.rdf -key Torbutton

   # Copy the signed update.rdf into place in the website svn

#. Update update.rdf

   cd website-svn
   vim ./include/versions.wmi   # Add sha1 and version
   cp /mnt/update-signed.rdf ./torbutton/update.rdf

#. Update website

   torsocks svn up .
   torsocks svn commit .

   torsocks ssh vescum "/home/mirroradm/bin/trigger-mirrors"

#. Test firefox autoupdate

   # Wait for mirrors to sync first.. Pester phobos/weasel/helix/Sebastian for
   # website push + dist chown + mirror update.
   # TODO: Currently manual

#. Announce on tor-talk

   # FIXME: May need eventual minor improvements
   echo "Troll food." | mail tor-talk@lists.torproject.org -s "Feed the trolls"
