diff --git a/.travis.yml b/.travis.yml index a4c92349..83c9ecf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ before_install: cabal) export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:$HOME/.cabal/bin:$PATH;; esac - - curl -L https://github.com/commercialhaskell/stack/releases/download/v1.6.1/stack-1.6.1-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C $HOME/.local/bin '*/stack' + - curl -L https://github.com/commercialhaskell/stack/releases/download/v1.7.1/stack-1.7.1-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C $HOME/.local/bin '*/stack' - curl -L https://github.com/google/protobuf/releases/download/v3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.zip > protoc-release.zip - unzip -p protoc-release.zip protoc > $HOME/.local/bin/protoc - chmod a+x $HOME/.local/bin/protoc diff --git a/docs/releasing.md b/docs/releasing.md index a2ebe9e1..af0cf7a1 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -17,26 +17,8 @@ since they are intended only for use within this repository: - Make sure you are on a commit that has been merged upstream to `google/proto-lens`. ## Steps -1. For each package *without* autogenerated proto modules, simply run (from the root of the repo): +First, run `stack build` at the top level. Then, for each package that you want to upload, run stack upload {name-of-package} - Then verify that they've been uploaded successfully by visiting `hackage.org` in a web browser. - -2. For packages *with* autogenerated proto-modules (currently: -`proto-lens-protobuf-types` and `proto-lens-combinators`): these are a little -harder to upload due to #185. We have a script for running `sdist`: - - ./release.sh - - Then, for each package that should be uploaded: - - cabal upload {package}/dist/{path}.tar.gz - -3. Finally, tag each uploaded package with its version and push it back to upstream. For example: - - git tag -a proto-lens-v0.3.0.0 -m "Release proto-lens v0.3.0.0" - ... - git remote add upstream git@github.com:google/proto-lens.git - git push upstream --follow-tags # See: https://stackoverflow.com/a/26438076 - +Then verify that they've been uploaded successfully by visiting `hackage.org` in a web browser. diff --git a/proto-lens-combinators/package.yaml b/proto-lens-combinators/package.yaml index caecf3a8..77d8d628 100644 --- a/proto-lens-combinators/package.yaml +++ b/proto-lens-combinators/package.yaml @@ -48,3 +48,10 @@ tests: other-modules: Proto.Combinators Proto.Combinators_Fields + # Manually list autogenerated modules, to avoid hpack + # adding a `cabal-version: >= 2.0`. + verbatim: + - | + autogen-modules: + Proto.Combinators + Proto.Combinators_Fields diff --git a/proto-lens-discrimination/package.yaml b/proto-lens-discrimination/package.yaml index b365c01f..bdea96ca 100644 --- a/proto-lens-discrimination/package.yaml +++ b/proto-lens-discrimination/package.yaml @@ -54,3 +54,10 @@ tests: other-modules: - Proto.Enum - Proto.Enum_Fields + # Manually list autogenerated modules, to avoid hpack + # adding a `cabal-version: >= 2.0`. + verbatim: + - | + autogen-modules: + Proto.Enum + Proto.Enum_Fields diff --git a/proto-lens-protobuf-types/package.yaml b/proto-lens-protobuf-types/package.yaml index 367e03ea..ab86a6e9 100644 --- a/proto-lens-protobuf-types/package.yaml +++ b/proto-lens-protobuf-types/package.yaml @@ -42,3 +42,16 @@ library: - Proto.Google.Protobuf.Wrappers_Fields - Proto.Google.Protobuf.Timestamp - Proto.Google.Protobuf.Timestamp_Fields + # Manually list autogenerated modules, to avoid hpack + # adding a `cabal-version: >= 2.0`. + verbatim: + - | + autogen-modules: + Proto.Google.Protobuf.Any + Proto.Google.Protobuf.Any_Fields + Proto.Google.Protobuf.Duration + Proto.Google.Protobuf.Duration_Fields + Proto.Google.Protobuf.Wrappers + Proto.Google.Protobuf.Wrappers_Fields + Proto.Google.Protobuf.Timestamp + Proto.Google.Protobuf.Timestamp_Fields diff --git a/proto-lens-protoc/src/Data/ProtoLens/Setup.hs b/proto-lens-protoc/src/Data/ProtoLens/Setup.hs index cb168e72..d71febb0 100644 --- a/proto-lens-protoc/src/Data/ProtoLens/Setup.hs +++ b/proto-lens-protoc/src/Data/ProtoLens/Setup.hs @@ -185,11 +185,16 @@ generatingSpecificProtos root getProtos hooks = hooks { buildHook = \p l h f -> generate l >> buildHook hooks p l h f , haddockHook = \p l h f -> generate l >> haddockHook hooks p l h f , replHook = \p l h f args -> generate l >> replHook hooks p l h f args +#if !MIN_VERSION_Cabal(2,0,0) + -- Older versions of Cabal don't support the autogen-modules field. + -- Work around it by manually generating the modules and putting them + -- in a place where `cabal sdist` will pick them up. , sDistHook = \p maybe_l h f -> case maybe_l of Nothing -> error "Can't run protoc; run 'cabal configure' first." Just l -> do generate l sDistHook hooks (fudgePackageDesc l p) maybe_l h f +#endif , postCopy = \a flags pkg lbi -> do let verb = fromFlag $ copyVerbosity flags let destDir = datadir (absoluteInstallDirs pkg lbi diff --git a/proto-lens-tests-dep/package.yaml b/proto-lens-tests-dep/package.yaml index e7057f31..c79bec35 100644 --- a/proto-lens-tests-dep/package.yaml +++ b/proto-lens-tests-dep/package.yaml @@ -32,3 +32,10 @@ library: exposed-modules: - Proto.TestDep.Foo - Proto.TestDep.Foo_Fields + # Manually list autogenerated modules, to avoid hpack + # adding a `cabal-version: >= 2.0`. + verbatim: + - | + autogen-modules: + Proto.TestDep.Foo + Proto.TestDep.Foo_Fields diff --git a/release.sh b/release.sh deleted file mode 100755 index 289c7828..00000000 --- a/release.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -ueo pipefail - -cabal sandbox init -export CABAL_SANDBOX_CONFIG=$PWD/cabal.sandbox.config - -for p in lens-labels proto-lens proto-lens-protoc -do - (cd $p && \ - cabal install --force-reinstall) -done - -for p in proto-lens-combinators proto-lens-protobuf-types -do - (cd $p && \ - cabal install --enable-tests --enable-benchmarks --only-dependencies && \ - cabal configure --enable-tests --enable-benchmarks && \ - cabal sdist) -done - diff --git a/travis-cabal.sh b/travis-cabal.sh index 5be2eede..6eb46a7b 100755 --- a/travis-cabal.sh +++ b/travis-cabal.sh @@ -12,7 +12,11 @@ chmod +x $HOME/.local/bin/hpack # List all the packages in this repo. Put certain ones first since # they're dependencies of the others. (Unfortunately, "stack query" doesn't # give them to us in the right order.) -PACKAGES=" + +# All the packages that are prepared to be test-released. +# Don't include test packages, some of which require +# Cabal-2.0 or higher during `sdist` due to using hpack. +PACKAGES_TO_INSTALL=" discrimination-ieee754 lens-labels proto-lens @@ -21,12 +25,17 @@ PACKAGES=" proto-lens-arbitrary proto-lens-combinators proto-lens-optparse + proto-lens-discrimination proto-lens-tests-dep +" + +PACKAGES_TO_BUILD=" proto-lens-tests - proto-lens-discrimination proto-lens-benchmarks -" -echo Building: $PACKAGES +""" + +echo Installing: ${PACKAGES_TO_INSTALL} +echo Building: ${PACKAGES_TO_BUILD} # Needed by haskell-src-exts which is a dependency of proto-lens-protoc. # Sadly, Cabal won't install such build-tools automatically. @@ -35,33 +44,47 @@ cabal install happy # Unregister the already-installed packages, since otherwise they may # propagate between builds. # TODO: use a Cabal sandbox for this. -for p in $PACKAGES +for p in $PACKAGES_TO_INSTALL do echo "Unregistering $p" ghc-pkg unregister --force $p || true done -for p in $PACKAGES +function build_package () { + if [ -f package.yaml ] + # Generate the .cabal file + then hpack + fi + cabal clean + cabal install --enable-tests --force --only-dependencies + cabal configure --enable-tests --enable-benchmarks + cabal build +} + + +for p in $PACKAGES_TO_INSTALL do - echo "Cabal building $p" + echo "Cabal installing $p" (cd $p && - hpack # Generate the .cabal file - cabal clean - cabal install --enable-tests --only-dependencies - cabal configure --enable-tests --enable-benchmarks - cabal build - cabal sdist - SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz"; exit}') - cd dist - if [ -f "$SRC_TGZ" ]; then - cabal install --force-reinstalls "$SRC_TGZ" - else - echo "expected '$SRC_TGZ' not found" - exit 1 - fi + build_package + cabal sdist + SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz"; exit}') + cd dist + if [ -f "$SRC_TGZ" ]; then + cabal install --force-reinstalls "$SRC_TGZ" + else + echo "expected '$SRC_TGZ' not found" + exit 1 + fi ) done +for p in $PACKAGES_TO_BUILD +do + echo "Cabal building $p" + (cd $p && build_package) +done + # Check that "cabal repl" works on a simple test. cd proto-lens-tests # Get rid of the previous dist/autogen to make sure "cabal repl" rebuilds it.