Skip to content

Commit

Permalink
update docs generation script to work better with selinux (#30)
Browse files Browse the repository at this point in the history
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

Co-authored-by: Cory Benfield <[email protected]>
  • Loading branch information
tomerd and Lukasa authored Mar 4, 2020
1 parent 2005387 commit 0473010
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scripts/generate_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ if [[ "$(uname -s)" == "Linux" ]]; then
done
fi

jazzy_dir="$root_path/.build/jazzy"
rm -rf "$jazzy_dir"
mkdir -p "$jazzy_dir"

# prep index
tmp=`mktemp -d`
module_switcher="$tmp/README.md"
module_switcher="$jazzy_dir/README.md"
cat > "$module_switcher" <<"EOF"
# SwiftCrypto Docs
Expand All @@ -70,21 +73,24 @@ jazzy_args=(--clean
--swift-build-tool spm)

for module in "${modules[@]}"; do
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-crypto/docs/$version/$module/")
if [[ "$(uname -s)" == "Linux" ]]; then
args+=(--sourcekitten-sourcefile "$root_path/.build/sourcekitten/$module.json")
fi
jazzy "${args[@]}"
done

# push to github pages
if [[ $CI == true ]]; then
if [[ $PUSH == true ]]; then
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
GIT_AUTHOR=$(git --no-pager show -s --format='%an <%ae>' HEAD)
git fetch origin +gh-pages:gh-pages
git checkout gh-pages
rm -rf "docs"
cp -r "$tmp/docs" .
rm -rf "docs/$version"
rm -rf "docs/current"
cp -r "$jazzy_dir/docs/$version" docs/
cp -r "docs/$version" docs/current
git add --all docs
echo '<html><head><meta http-equiv="refresh" content="0; url=docs/current/Crypto/index.html" /></head></html>' > index.html
Expand Down

0 comments on commit 0473010

Please sign in to comment.