Skip to content

Commit

Permalink
Update doc workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Mar 31, 2023
1 parent 414f920 commit b494e14
Showing 1 changed file with 30 additions and 67 deletions.
97 changes: 30 additions & 67 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,25 @@ on:
push:
branches:
- main
- protocol-clocks
workflow_dispatch:

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-12
steps:
- name: Select Xcode 14.1
run: sudo xcode-select -s /Applications/Xcode_14.1.app

- name: Checkout Package
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Download Swift 5.5.1
run: wget -q https://download.swift.org/swift-5.5.1-release/ubuntu2004/swift-5.5.1-RELEASE/swift-5.5.1-RELEASE-ubuntu20.04.tar.gz
- name: Extract Swift 5.5.1
run: tar xzf swift-5.5.1-RELEASE-ubuntu20.04.tar.gz
- name: Add Swift toolchain to PATH
run: |
echo "$GITHUB_WORKSPACE/swift-5.5.1-RELEASE-ubuntu20.04/usr/bin" >> $GITHUB_PATH
- name: Checkout swift-docc
uses: actions/checkout@v2
with:
repository: apple/swift-docc
ref: main
path: swift-docc
- name: Cache DocC
id: cache-docc
uses: actions/cache@v2
with:
key: swift-url-docc-build
path: swift-docc/.build
- name: Build swift-docc
if: ${{ !steps.cache-docc.outputs.cache-hit }}
run: |
cd swift-docc; swift build --product docc -c release; cd ..
- name: Checkout swift-docc-render
uses: actions/checkout@v2
with:
repository: apple/swift-docc-render
ref: main
path: swift-docc-render
- name: Build swift-docc-render
run: |
cd swift-docc-render; npm install && npm run build; cd ..
- name: Checkout gh-pages Branch
uses: actions/checkout@v2
with:
Expand All @@ -65,45 +38,35 @@ jobs:
run: >
rm -rf docs-out/.git;
rm -rf docs-out/main;
git tag -l --sort=-v:refname | grep -e "\d\+\.\d\+.0" | tail -n +6 | xargs -I {} rm -rf {};
for tag in $(echo "main"; git tag);
for tag in $(echo "main"; git tag -l --sort=-v:refname | grep -e "\d\+\.\d\+.0" | head -6);
do
echo "⏳ Generating documentation for "$tag" release.";
if [ -d "docs-out/$tag" ]
if [ -d "docs-out/$tag/data/documentation/urlrouting" ]
then
echo "✅ Documentation for "$tag" already exists.";
echo "✅ Documentation for "$tag" already exists.";
else
git checkout "$tag";
mkdir -p Sources/URLRouting/Documentation.docc;
export DOCC_HTML_DIR="$(pwd)/swift-docc-render/dist";
echo "⏳ Generating documentation for URLRouting @ "$tag" release.";
rm -rf "docs-out/$tag";
rm -rf .build/symbol-graphs;
mkdir -p .build/symbol-graphs;
swift build \
--target URLRouting \
-Xswiftc \
-emit-symbol-graph \
-Xswiftc \
-emit-symbol-graph-dir \
-Xswiftc \
.build/symbol-graphs \
&& swift-docc/.build/release/docc convert Sources/URLRouting/Documentation.docc \
--fallback-display-name URLRouting \
--fallback-bundle-identifier co.pointfree.URLRouting \
--fallback-bundle-version 0.0.0 \
--additional-symbol-graph-dir \
.build/symbol-graphs \
--transform-for-static-hosting \
--hosting-base-path /swift-url-routing/"$tag" \
--output-path docs-out/"$tag" \
&& echo "✅ Documentation generated for "$tag" release." \
|| echo "⚠️ Documentation skipped for "$tag".";
git checkout .;
git checkout "$tag";
swift package \
--allow-writing-to-directory docs-out/"$tag" \
generate-documentation \
--target URLRouting \
--output-path docs-out/"$tag" \
--transform-for-static-hosting \
--hosting-base-path /swift-url-routing/"$tag" \
&& echo "✅ Documentation generated for URLRouting @ "$tag" release." \
|| echo "⚠️ Documentation skipped for URLRouting @ "$tag".";
fi;
done
- name: Fix permissions
run: 'sudo chown --recursive $USER docs-out'
run: 'sudo chown -R $USER docs-out'

- name: Publish documentation to GitHub Pages
uses: JamesIves/github-pages-deploy-action@4.1.7
with:
Expand Down

0 comments on commit b494e14

Please sign in to comment.