Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build & Publish Zig docs

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: read
pages: write
id-token: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: '0.13.0'

- name: Build docs
run: zig build docs

- name: Verify docs produced
run: |
ls -la zig-out/docs || (echo "ERROR: zig-out/docs not found" && exit 1)

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: zig-out/docs

- name: Configure GitHub Pages
uses: actions/configure-pages@v5

- name: Deploy to GitHub Pages (only on push to main)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/deploy-pages@v4

7 changes: 7 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@ pub fn build(b: *std.Build) void {
b.installArtifact(default_config);
}

const install_docs = b.addInstallDirectory(.{
.source_dir = lib.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});
const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const test_step = b.step("test", "Run unit tests");
const docs_step = b.step("docs", "Generate documentation");
test_step.dependOn(&run_lib_unit_tests.step);
docs_step.dependOn(&install_docs.step);
}