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>.

* Update the version numbers in Agda.cabal,
  src/main/Agda-executable.cabal (two places) and
  ../src/data/emacs-mode/agda2-mode.el.

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

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

* Tag and build source distributions.

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

  Note that configuring Agda-executable will not work unless the Agda
  library is first installed. Note also that cabal check may warn
  about -Werror.

* Ensure that all the packages build properly.

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

  Do not forget to test the Emacs mode.

* Upload the Cabal packages using cabal upload.

    cd $BASE
    cabal upload dist/Agda-$VERSION.tar.gz \
                 src/main/dist/Agda-executable-$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.

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

* Push all changes.

    darcs push
