rtic/ci/after-success.sh

78 lines
2.1 KiB
Bash
Raw Normal View History

2018-08-27 14:44:47 +02:00
set -euxo pipefail
main() {
2019-02-11 22:07:15 +01:00
local langs=( en ru )
local latest=0.5
local vers=( 0.4.x )
2019-02-11 22:07:15 +01:00
2018-11-03 17:02:41 +01:00
rm -f .cargo/config
2019-09-15 20:19:48 +02:00
cargo doc
2018-08-27 14:44:47 +02:00
2018-11-03 17:02:41 +01:00
local td=$(mktemp -d)
2019-09-15 20:19:48 +02:00
# build latest docs
2019-09-17 09:55:05 +02:00
mkdir -p $td/$latest/book/
cp -r target/doc $td/$latest/api
2020-06-11 19:18:29 +02:00
sed 's|URL|rtic/index.html|g' redirect.html > $td/$latest/api/index.html
2019-09-15 21:40:40 +02:00
sed 's|URL|0.5|g' redirect.html > $td/index.html
sed 's|URL|book/en|g' redirect.html > $td/$latest/index.html
2019-02-11 22:07:15 +01:00
for lang in ${langs[@]}; do
( cd book/$lang && mdbook build )
2019-09-17 09:55:05 +02:00
cp -r book/$lang/book $td/$latest/book/$lang
cp LICENSE-* $td/$latest/book/$lang/
2019-02-11 22:07:15 +01:00
done
2018-08-27 14:44:47 +02:00
local root=$(pwd)
2019-09-15 20:19:48 +02:00
# build older docs
for ver in ${vers[@]}; do
local prefix=${ver%.*}
mkdir -p $td/$prefix/book
local src=$(mktemp -d)
2020-06-11 19:18:29 +02:00
curl -L https://github.com/rtic-rs/cortex-m-rtic/archive/v${ver}.tar.gz | tar xz --strip-components 1 -C $src
2019-09-15 20:19:48 +02:00
pushd $src
2019-09-15 22:05:17 +02:00
rm -f .cargo/config
2019-09-15 20:19:48 +02:00
cargo doc || cargo doc --features timer-queue
cp -r target/doc $td/$prefix/api
2020-06-11 19:18:29 +02:00
sed 's|URL|rtic/index.html|g' $root/redirect.html > $td/$prefix/api/index.html
2019-09-15 20:19:48 +02:00
for lang in ${langs[@]}; do
( cd book/$lang && mdbook build )
cp -r book/$lang/book $td/$prefix/book/$lang
cp LICENSE-* $td/$prefix/book/$lang/
done
sed 's|URL|book/en|g' $root/redirect.html > $td/$prefix/index.html
2019-09-15 20:19:48 +02:00
popd
rm -rf $src
done
2019-09-15 21:40:40 +02:00
# forward CNAME file
cp CNAME $td/
2018-11-03 17:02:41 +01:00
mkdir ghp-import
2018-08-27 14:44:47 +02:00
curl -Ls https://github.com/davisp/ghp-import/archive/master.tar.gz |
tar --strip-components 1 -C ghp-import -xz
2018-11-03 17:02:41 +01:00
./ghp-import/ghp_import.py $td
2018-08-27 14:44:47 +02:00
set +x
2020-06-11 19:18:29 +02:00
git push -fq https://$GH_TOKEN@github.com/rtic-rs/cortex-m-rtic.git gh-pages && echo OK
2018-11-03 17:02:41 +01:00
rm -rf $td
2018-08-27 14:44:47 +02:00
}
# fake Travis variables to be able to run this on a local machine
if [ -z ${TRAVIS_BRANCH-} ]; then
TRAVIS_BRANCH=master
fi
if [ -z ${TRAVIS_PULL_REQUEST-} ]; then
TRAVIS_PULL_REQUEST=false
fi
2018-11-03 17:02:41 +01:00
if [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ]; then
2018-08-27 14:44:47 +02:00
main
fi