mirror of
https://github.com/byteverse/colonnade.git
synced 2024-09-11 06:45:41 +03:00
49 lines
1.3 KiB
Bash
49 lines
1.3 KiB
Bash
|
#!/bin/bash
|
||
|
set -e
|
||
|
|
||
|
if [ "$#" -ne 1 ]; then
|
||
|
echo "Usage: scripts/hackage-docs.sh HACKAGE_USER"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
user=$1
|
||
|
|
||
|
cabal_file=$(find . -maxdepth 1 -name "*.cabal" -print -quit)
|
||
|
if [ ! -f "$cabal_file" ]; then
|
||
|
echo "Run this script in the top-level package directory"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
pkg=$(awk -F ":[[:space:]]*" 'tolower($1)=="name" { print $2 }' < "$cabal_file")
|
||
|
ver=$(awk -F ":[[:space:]]*" 'tolower($1)=="version" { print $2 }' < "$cabal_file")
|
||
|
|
||
|
if [ -z "$pkg" ]; then
|
||
|
echo "Unable to determine package name"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ -z "$ver" ]; then
|
||
|
echo "Unable to determine package version"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
echo "Detected package: $pkg-$ver"
|
||
|
|
||
|
dir=$(mktemp -d build-docs.XXXXXX)
|
||
|
trap 'rm -r "$dir"' EXIT
|
||
|
|
||
|
# cabal haddock --hoogle --hyperlink-source --html-location='/package/$pkg-$version/docs' --contents-location='/package/$pkg-$version'
|
||
|
stack haddock
|
||
|
|
||
|
cp -R .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/doc/html/$pkg/ $dir/$pkg-$ver-docs
|
||
|
# /home/andrew/.stack/snapshots/x86_64-linux/lts-5.17/7.10.3/doc/index.html
|
||
|
|
||
|
tar cvz -C $dir --format=ustar -f $dir/$pkg-$ver-docs.tar.gz $pkg-$ver-docs
|
||
|
|
||
|
curl -X PUT \
|
||
|
-H 'Content-Type: application/x-tar' \
|
||
|
-H 'Content-Encoding: gzip' \
|
||
|
-u "$user" \
|
||
|
--data-binary "@$dir/$pkg-$ver-docs.tar.gz" \
|
||
|
"https://hackage.haskell.org/package/$pkg-$ver/docs"
|