build-docc is a GitHub Action for generating Swift DocC documentation with support for multiple schemes and versioning.
This action builds your DocC archive using Xcode and outputs a static documentation website that you can deploy anywhere (GitHub Pages, S3, etc).
- π― Multiple Schemes Support - Build documentation for multiple frameworks/libraries in one go
- π¦ Version Management - Automatic versioning with option to preserve or replace old versions
- π Flexible Xcode Versions - Choose any Xcode version for building
- π Static Hosting Ready - Generates documentation optimized for GitHub Pages or any static hosting
- π Easy Integration - Simple YAML configuration with sensible defaults
- Quick Start
- Inputs
- Outputs
- Usage Examples
- Version Management
- Deployment to GitHub Pages
- Generated Structure
- Advanced Usage
- FAQ
- Communication
- License
- name: Build Documentation
uses: space-code/build-docc@v1
with:
schemes: '["MyFramework"]'
version: 'v1.0.0'
name: Generate Documentation
on:
push:
tags:
- 'v*'
jobs:
build-and-deploy:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Documentation
uses: space-code/build-docc@v1
with:
schemes: '["MyLib", "MyUI"]'
version: ${{ github.ref_name }}
keep-old-versions: 'true'
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
keep_files: true
| Input | Description | Required | Default |
|---|---|---|---|
schemes |
JSON array of schemes to build (e.g. ["MyLib", "MyUI"]) |
β Yes | - |
version |
Documentation version (e.g. v1.0.0, latest) |
β No | latest |
xcode-version |
Xcode version to use for building | β No | latest-stable |
keep-old-versions |
Keep old versions in docs/ directory | β No | true |
| Output | Description |
|---|---|
docs-path |
Path to the generated docs folder |
version |
Version used for build |
- uses: space-code/build-docc@v1
with:
schemes: '["MyFramework"]'
version: 'v1.0.0'- uses: space-code/build-docc@v1
with:
schemes: '["CoreLib", "UIComponents", "Networking"]'
version: ${{ github.ref_name }}- uses: space-code/build-docc@v1
with:
schemes: '["MyFramework"]'
version: 'v2.0.0'
xcode-version: '15.0'- uses: space-code/build-docc@v1
with:
schemes: '["MyFramework"]'
version: 'latest'
keep-old-versions: 'false'The action supports two modes for handling documentation versions:
When keep-old-versions: 'true' (default):
- Previous versions remain accessible
- New version is added alongside existing ones
- Perfect for maintaining documentation history
docs/
βββ v1.0.0/
β βββ MyLib/
βββ v1.1.0/
β βββ MyLib/
βββ v2.0.0/
βββ MyLib/
When keep-old-versions: 'false':
- Previous versions are removed
- Only the new version is kept
- Useful for "latest" documentation or saving storage
docs/
βββ latest/
βββ MyLib/
name: Documentation
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
jobs:
build-docs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: docs
continue-on-error: true
- name: Build Documentation
uses: space-code/build-docc@v1
with:
schemes: '["MyFramework"]'
version: ${{ github.ref_name }}
keep-old-versions: 'true'
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
keep_files: true- Go to your repository Settings β Pages
- Set Source to "Deploy from a branch"
- Select gh-pages branch and / (root) folder
- Save
Your documentation will be available at:
https://your-username.github.io/your-repo/v1.0.0/MyFramework/
The action generates the following structure:
docs/
βββ v1.0.0/
β βββ MyLib/
β β βββ index.html
β β βββ documentation/
β β βββ data/
β β βββ css/
β βββ MyUI/
β βββ index.html
β βββ ...
βββ v2.0.0/
βββ MyLib/
βββ ...
Each version contains fully static HTML documentation that can be hosted anywhere.
- name: Build Documentation
id: docc
uses: space-code/build-docc@v1
with:
schemes: '["MyFramework"]'
version: 'v1.0.0'
- name: Archive Documentation
run: |
tar -czf docs.tar.gz ${{ steps.docc.outputs.docs-path }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: documentation-${{ steps.docc.outputs.version }}
path: docs.tar.gzjobs:
docs:
runs-on: macos-latest
strategy:
matrix:
project:
- name: 'Project A'
schemes: '["LibA", "UtilsA"]'
- name: 'Project B'
schemes: '["LibB"]'
steps:
- uses: actions/checkout@v4
- name: Build ${{ matrix.project.name }}
uses: space-code/build-docc@v1
with:
schemes: ${{ matrix.project.schemes }}
version: ${{ github.ref_name }}# For Swift Package Manager
swift package describe | grep "Name:"
# For Xcode projects
xcodebuild -listYes! As long as your project has Xcode schemes, the action will work. Just ensure your schemes are shared.
- π Found a bug? Open an issue
- π‘ Have a feature request? Open an issue
- β Questions? Start a discussion
- π Security issue? Email [email protected]
Contributions are welcome! Please feel free to submit issues or pull requests.
Nikita Vasilev
- Email: [email protected]
- GitHub: @ns-vasilev
build-docc is released under the MIT license. See LICENSE for details.
Made with β€οΈ by space-code
