When releasing a release candidate (RC) the following procedure can be
followed:

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

  Copy the contents of the release notes to the top of the CHANGELOG
  file.

* Run the `closed-issues` program for adding the closed issues to the
  CHANGELOG excluding issues labelled with:

  not-in-changelog,
  status: abandoned,
  status: duplicated,
  status: invalid,
  status: wontfix,
  status: working-as-intended or

* Update the README.md, if necessary.

* Update the list of contributors if necessary.

  Note: This is duplicated in the following locations:

  - Agda.cabal
  - doc/user-manual/conf.py
  - doc/user-manual/team.rst
  - LICENSE

* Update the LICENSE file, if necessary.

* Update Stackage resolvers, if necessary.

* Verify that the Travis builds have no errors.

* Get a clean Agda repository.

    MAJORVERSION=<current-development-version-eg-2.4.2>
    VERSION=<current-released-version-eg-2.4.0.2>
    git clone git@github.com:agda/agda.git agda-release
    cd agda-release
    git checkout master

* Create the branch used for the release

    git checkout -b release-$MAJORVERSION

* The version of the RC is $VERSION + current date

    RC_VERSION=<current-released-version-current-date-eg-2.4.0.2.20150913>

* The $CHANGE_VERSION_FILES variable represents the files where it is
  necessary to change the version number.

    $CHANGE_VERSION_FILES=
      .ghci
      Agda.cabal
      default.nix
      doc/user-manual/conf.py
      mk/versions.mk
      src/data/emacs-mode/agda2-mode.el
      src/data/emacs-mode/agda2-mode-pkg.el
      src/size-solver/size-solver.cabal
      test/interaction/Issue1244a.out
      test/interaction/Issue1244b.out

* Change $MAYOR_VERSION to $RC_VERSION in $CHANGE_VERSION_FILES.

* Obtain and install the standard library branch related to the Agda:

    make up-to-date-std-lib

* Run the test-suite:

    make compile-emacs-mode
    make test

  Note that "compile-emacs-mode" invokes "agda-mode compile", which should
  ensure that the Emacs mode can be compiled without errors or
  warnings (except for the "cl package required at runtime" warning).

* Remove -Werror and -fprof-auto from Agda.cabal (this is required by
  `cabal --check`).

* Remove the Cabal test-suite from Agda.cabal.

* Update the user manual:

    make user-manual-pdf

* Build source distributions:

    cabal configure
    cabal check
    cabal sdist

* Build documentation for uploading to Hackage. Adapted from
  https://hackage.haskell.org/upload (2018-07-19):

    cabal haddock --for-hackage

* Ensure that the package builds properly (with multiple versions of
  GHC if possible) in Linux, macOS and Windows.

    BASE=`pwd`
    cd ${TMPDIR:-/tmp}
    tar xzf $BASE/dist/Agda-$RC_VERSION.tar.gz
    cd Agda-$RC_VERSION
    cabal install

  Do not forget to test the Emacs mode.

* Tag the release candidate (do not forget to record the changes above
  first):

    cd $BASE
    git tag -a v$RC_VERSION -m "Agda $MAJORVERSION release candidate n"

* Upload to Hackage the RC (tested with cabal-install >= 2.0.0.0):

    cd $BASE
    cabal upload dist/Agda-$RC_VERSION.tar.gz
    cabal upload -d dist/Agda-$RC_VERSION-docs.tar.gz

* Restore the Cabal test-suite in Agda.cabal.

* Restore -Werror and -fprof-auto in Agda.cabal.

* Restore the version number $MAJOR_VERSION in $CHANGE_VERSION_FILES.

* Push all changes (in the release-$MAJORVERSION branch):

    git push --set-upstream --follow-tags

* Announce the release candidate on the Agda mailing lists (users and
  developers).
