When releasing a new version of Agda, the following procedure can be
followed:

* Get a clean Agda repository.

    darcs get http://code.haskell.org/Agda/ Agda.release
    cd Agda.release

* Finish the release notes in
  doc/release-notes/<version-written-with-dashes>.txt.

* Update the README, if necessary.

* Update the version numbers in Agda.cabal (twice) and
  src/data/emacs-mode/agda2-mode.el.

* Add a second source-repository section to Agda.cabal:

    source-repository this
      type:     darcs
      location: http://code.haskell.org/Agda/
      tag:      <version>

* Remove -Werror from Agda.cabal.

  (Agda uses code generated by Cabal, Paths_Agda, and under some
  configurations this code gives rise to warnings.)

* Ensure that cabal haddock works:

    cabal configure && cabal haddock

* Ensure that the Emacs mode can be compiled without errors or
  warnings (except for the "cl package required at runtime" warning):

    (cd src/data/emacs-mode && \
      emacs --batch -L . -f batch-byte-compile *.el; \
      rm -f *.elc)

* Tag and build source distributions. (Do not forget to record the
  changes above first.)

    VERSION=<version>
    darcs tag $VERSION
    cabal configure && cabal sdist && cabal check
    cabal install
    darcs dist --dist-name=Agda-$VERSION

* Ensure that all the packages build properly.

    BASE=`pwd`
    cd ${TMPDIR:-/tmp}
    tar xzf $BASE/Agda-$VERSION.tar.gz
    cd Agda-$VERSION
    make install CABAL_OPTIONS="--prefix=$PWD/usr"
    autoconf
    ./configure
    make test
    tar xzf $BASE/dist/Agda-$VERSION.tar.gz
    cd Agda-$VERSION
    cabal install
    cd ..

  Do not forget to test the Emacs mode.

* Upload the Cabal package using cabal upload.

    cd $BASE
    cabal upload dist/Agda-$VERSION.tar.gz

* Upload the darcs tar-ball to code.haskell.org.

    scp Agda-$VERSION.tar.gz code.haskell.org:/srv/code/Agda/

* Update the download page on the Agda Wiki.

* Announce the release of the new version on the Agda mailing list.

* Update the version numbers again, so that released and development
  versions are not confused, and remove the "this" source-repository
  section from the Cabal file. (This would be unnecessary if we had
  two repositories, one stable and one for development.)

* Push all changes.

    darcs push
