Skip to content

SPM

SPM #47

Workflow file for this run

name: DocC Documentation
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: docc-pages
cancel-in-progress: true
env:
DOCC_HOSTING_BASE_PATH: NavigationSplitView
jobs:
build:
name: Build DocC archive
runs-on: macos-15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Select Xcode 16.1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "16.1"
- name: Show Xcode version
run: xcodebuild -version
- name: Build documentation archive
run: |
set -eo pipefail
# Clean up any previous build artifacts
rm -rf DerivedData DocsArchive DocsBuild
# Use xcodebuild docbuild to build full documentation including API
# This will create both /documentation/ (API) and /tutorials/ sections
# DOCC_HOSTING_BASE_PATH is set in Xcode project, but we can override via environment
xcodebuild docbuild \
-project XcodeProject/NewNav.xcodeproj \
-scheme NewNav \
-derivedDataPath ./DerivedData \
-destination 'generic/platform=iOS Simulator' \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
DOCC_HOSTING_BASE_PATH="$DOCC_HOSTING_BASE_PATH"
# Find the generated .doccarchive
DOCCARCHIVE=$(find DerivedData -name "*.doccarchive" | head -1)
echo "Found doccarchive at: $DOCCARCHIVE"
# Copy to expected location
mkdir -p DocsArchive
cp -R "$DOCCARCHIVE" DocsArchive/NavigationSplitView.doccarchive
- name: Prepare static documentation output
run: |
set -eo pipefail
# The DOCC_HOSTING_BASE_PATH is now set in Xcode project settings
# so DocC will generate the correct paths automatically
xcrun docc process-archive transform-for-static-hosting DocsArchive/NavigationSplitView.doccarchive \
--hosting-base-path "$DOCC_HOSTING_BASE_PATH" \
--output-path DocsBuild
echo "=== Documentation processed for static hosting ==="
echo "Hosting base path: $DOCC_HOSTING_BASE_PATH"
echo ""
echo "=== Directory structure ==="
find DocsBuild -type d | sort
echo ""
echo "=== Files in documentation directory ==="
find DocsBuild/documentation -type f 2>/dev/null | head -20 || echo "No documentation directory found"
echo ""
echo "=== Files in tutorials directory ==="
find DocsBuild/tutorials -type f 2>/dev/null | head -20 || echo "No tutorials directory found"
echo ""
echo "=== Root level files ==="
ls -la DocsBuild/
echo ""
echo "=== Index directory contents ==="
ls -la DocsBuild/index/ 2>/dev/null || echo "No index directory"
echo ""
echo "=== Data directory structure ==="
find DocsBuild/data -type f 2>/dev/null | head -10 || echo "No data directory"
echo ""
echo "=== metadata.json content ==="
cat DocsBuild/metadata.json 2>/dev/null || echo "No metadata.json"
echo ""
echo "=== Original index.html content ==="
cat DocsBuild/index.html
- name: Fix resource paths and add .nojekyll
run: |
# Add .nojekyll to prevent GitHub Pages from ignoring files starting with _
touch DocsBuild/.nojekyll
# Fix resource paths in HTML files
# Even with DOCC_HOSTING_BASE_PATH in Xcode, DocC still generates absolute paths
echo "=== Fixing resource paths in HTML files ==="
find DocsBuild -type f -name "*.html" -exec sed -i '' \
-e 's|var baseUrl = "/"|var baseUrl = "/'$DOCC_HOSTING_BASE_PATH'/"|g' \
-e 's|src="/js/|src="/'$DOCC_HOSTING_BASE_PATH'/js/|g' \
-e 's|src="/css/|src="/'$DOCC_HOSTING_BASE_PATH'/css/|g' \
-e 's|href="/css/|href="/'$DOCC_HOSTING_BASE_PATH'/css/|g' \
-e 's|href="/js/|href="/'$DOCC_HOSTING_BASE_PATH'/js/|g' \
-e 's|href="/documentation/|href="/'$DOCC_HOSTING_BASE_PATH'/documentation/|g' \
-e 's|href="/tutorials/|href="/'$DOCC_HOSTING_BASE_PATH'/tutorials/|g' \
-e 's|href="/favicon.ico"|href="/'$DOCC_HOSTING_BASE_PATH'/favicon.ico"|g' \
-e 's|href="/favicon.svg"|href="/'$DOCC_HOSTING_BASE_PATH'/favicon.svg"|g' \
{} +
# Fix paths in JavaScript files
echo "=== Fixing paths in JavaScript files ==="
find DocsBuild -type f -name "*.js" -exec sed -i '' \
-e 's|"/data/|"/'$DOCC_HOSTING_BASE_PATH'/data/|g' \
-e 's|"/documentation/|"/'$DOCC_HOSTING_BASE_PATH'/documentation/|g' \
-e 's|"/tutorials/|"/'$DOCC_HOSTING_BASE_PATH'/tutorials/|g' \
-e 's|"/index/|"/'$DOCC_HOSTING_BASE_PATH'/index/|g' \
{} +
# Fix paths in JSON data files
echo "=== Fixing paths in JSON files ==="
find DocsBuild/data -type f -name "*.json" -exec sed -i '' \
-e 's|"/documentation/|"/'$DOCC_HOSTING_BASE_PATH'/documentation/|g' \
-e 's|"/tutorials/|"/'$DOCC_HOSTING_BASE_PATH'/tutorials/|g' \
-e 's|"/images/|"/'$DOCC_HOSTING_BASE_PATH'/images/|g' \
-e 's|"/videos/|"/'$DOCC_HOSTING_BASE_PATH'/videos/|g' \
-e 's|"/downloads/|"/'$DOCC_HOSTING_BASE_PATH'/downloads/|g' \
{} + 2>/dev/null || echo "No JSON files to fix"
echo "=== Fixed paths ==="
echo "Fixed index.html:"
head -5 DocsBuild/index.html
- name: Create root redirect
run: |
# Create redirect from root to documentation/newnav
cat > DocsBuild/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Redirecting to NewNav Documentation</title>
<meta http-equiv="refresh" content="0; url=./documentation/newnav/">
<link rel="canonical" href="./documentation/newnav/">
</head>
<body>
<p>Redirecting to <a href="./documentation/newnav/">NewNav Documentation</a>...</p>
<script>window.location.href = "./documentation/newnav/";</script>
</body>
</html>
EOF
echo "Created redirect to documentation/newnav/"
- name: Upload documentation artifact
if: github.event_name == 'push'
uses: actions/upload-pages-artifact@v3
with:
path: DocsBuild
deploy:
name: Deploy documentation
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4