update docs generation script to work better with selinux (#63)

motivation: docs scripts is broken on selinux due to restriction on ssh-agent

changes:
* change the jazzy workspace to a directory accessible by the CI node so we can push from the agent instead of from the docker container
* dont remove older docs when pushing new ones
* add version inforamtion and source links
This commit is contained in:
tomer doron 2020-02-28 12:25:20 -08:00 committed by GitHub
parent 09b72f68ed
commit ab3f3ffe1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -52,9 +52,11 @@ if ! command -v jazzy > /dev/null; then
gem install jazzy --no-ri --no-rdoc gem install jazzy --no-ri --no-rdoc
fi fi
tmp=`mktemp -d` jazzy_dir="$root_path/.build/jazzy"
mkdir -p "$tmp/docs/$version" rm -rf "$jazzy_dir"
module_switcher="$tmp/docs/$version/README.md" mkdir -p "$jazzy_dir"
module_switcher="$jazzy_dir/README.md"
jazzy_args=(--clean jazzy_args=(--clean
--author 'SwiftMetrics team' --author 'SwiftMetrics team'
--readme "$module_switcher" --readme "$module_switcher"
@ -84,7 +86,9 @@ done
for module in "${modules[@]}"; do for module in "${modules[@]}"; do
echo "processing $module" echo "processing $module"
args=("${jazzy_args[@]}" --output "$tmp/docs/$version/$module" --docset-path "$tmp/docset/$version/$module" --module "$module") args=("${jazzy_args[@]}" --output "$jazzy_dir/docs/$version/$module" --docset-path "$jazzy_dir/docset/$version/$module"
--module "$module" --module-version $version
--root-url "https://apple.github.io/swift-metrics/docs/$version/$module/")
if [[ -f "$root_path/.build/sourcekitten/$module.json" ]]; then if [[ -f "$root_path/.build/sourcekitten/$module.json" ]]; then
args+=(--sourcekitten-sourcefile "$root_path/.build/sourcekitten/$module.json") args+=(--sourcekitten-sourcefile "$root_path/.build/sourcekitten/$module.json")
fi fi
@ -92,13 +96,14 @@ for module in "${modules[@]}"; do
done done
# push to github pages # push to github pages
if [[ $CI == true ]]; then if [[ $PUSH == true ]]; then
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
GIT_AUTHOR=$(git --no-pager show -s --format='%an <%ae>' HEAD) GIT_AUTHOR=$(git --no-pager show -s --format='%an <%ae>' HEAD)
git fetch origin +gh-pages:gh-pages git fetch origin +gh-pages:gh-pages
git checkout gh-pages git checkout gh-pages
rm -rf "docs" rm -rf "docs/$version"
cp -r "$tmp/docs" . rm -rf "docs/current"
cp -r "$jazzy_dir/docs/$version" docs/
cp -r "docs/$version" docs/current cp -r "docs/$version" docs/current
git add --all docs git add --all docs
echo '<html><head><meta http-equiv="refresh" content="0; url=docs/current/CoreMetrics/index.html" /></head></html>' > index.html echo '<html><head><meta http-equiv="refresh" content="0; url=docs/current/CoreMetrics/index.html" /></head></html>' > index.html