Automate Hackage release
Manual Hackage releases can lag considerably - I just released https://hackage.haskell.org/package/postgrest-9.0.0 :man_facepalming:
This should be automated on CI.
Steps I follow:
$ nix-shell
$ cabal v2-haddock --haddock-for-hackage --enable-doc
$ cabal sdist # might not be necessary
$ cabal upload dist-newstyle/sdist/postgrest-9.0.0.tar.gz
hackage.haskell.org username:
hackage.haskell.org password:
Uploading dist-newstyle/sdist/postgrest-9.0.0.tar.gz...
Error uploading dist-newstyle/sdist/postgrest-9.0.0.tar.gz: http code 400
Error: Invalid package
'ghc-options: -fhpc' is not necessary. Use the configure flag
--enable-coverage instead.
# I manually remove the fhpc from postgrest.cabal and run cabal sdist again
$ cabal upload dist-newstyle/sdist/postgrest-9.0.0.tar.gz
hackage.haskell.org username:
hackage.haskell.org password:
Uploading dist-newstyle/sdist/postgrest-9.0.0.tar.gz...
Error uploading dist-newstyle/sdist/postgrest-9.0.0.tar.gz: http code 400
Error: Invalid package
'ghc-options: -Wall -Werror' makes the package very easy to break with future
GHC versions because new GHC versions often add new warnings. Use just
'ghc-options: -Wall' instead. Alternatively, if you want to use this, make it
conditional based on a Cabal configuration flag (with 'manual: True' and
'default: False') and enable that flag during development.
# Same with above, rerun cabal sdist
$ cabal upload dist-newstyle/sdist/postgrest-9.0.0.tar.gz
hackage.haskell.org username:
hackage.haskell.org password:
Uploading dist-newstyle/sdist/postgrest-9.0.0.tar.gz...
Package successfully uploaded as candidate. You can now preview the result at
'https://hackage.haskell.org/package/postgrest-9.0.0/candidate'. To publish
the candidate, use 'cabal upload --publish'.
Warnings:
- 'ghc-options: -O0' is not needed. Use the --disable-optimization configure
flag.
- 'ghc-options: -O0' is not needed. Use the --disable-optimization configure
flag.
- 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit
and not just imposing longer compile times on your users.
# The above succeeded
# For docs
cabal upload -d dist-newstyle/postgrest-9.0.0-docs.tar.gz
hackage.haskell.org username:
hackage.haskell.org password:
Uploading documentation dist-newstyle/postgrest-9.0.0-docs.tar.gz...
Documentation successfully uploaded for package candidate. You can now preview
the result at 'https://hackage.haskell.org/package/postgrest-9.0.0/candidate'.
To upload non-candidate documentation, use 'cabal upload --publish'.
# The above were just for generating a candidate for CI we should use the following directly
$ cabal upload --publish dist-newstyle/sdist/postgrest-9.0.0.tar.gz
$ cabal upload -d --publish dist-newstyle/postgrest-9.0.0-docs.tar.gz
We should probably clear some of those warnings with flags in the .cabal file.
References:
- https://hackage.haskell.org/upload
- https://github.com/haskell/haskell-language-server/pull/2163 (Prior art)
- HACKAGE_AUTH_TOKEN env var already set up on our repo secrets
Timely hackage releases would be appreciated!
There are some ready made Github actions nowadays:
- https://github.com/haskell-actions/hackage-publish
- https://github.com/cachix/haskell-release-action
However this is currently blocked bc we use a fork of https://github.com/haskellari/postgresql-libpq:
https://github.com/PostgREST/postgrest/blob/e889ded32bdd00fd2795cc550a0f9cdc7fd06396/nix/overlays/haskell-packages.nix#L32-L40
https://github.com/PostgREST/postgresql-libpq, which is not on Hackage.
Here's the reminder to myself to revive this since the fork is not in place anymore
I have this on my list as well, but imho we first need to discuss versioning (again). Hackage requires PVP, which we don't follow (yet). I have some ideas, I just need to write them up.