From 404f7d928468fb23a13ff840e95a3ce212c8ed7e Mon Sep 17 00:00:00 2001 From: Simejo Date: Tue, 14 Oct 2025 20:00:57 +0200 Subject: [PATCH 1/2] added build step to generate documentation --- build.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.zig b/build.zig index 1cbb964..b62bd1e 100644 --- a/build.zig +++ b/build.zig @@ -26,6 +26,11 @@ 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, @@ -33,5 +38,7 @@ pub fn build(b: *std.Build) void { }); 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); } From 14e2be09f11c4b62e34487f99fe82b4969680139 Mon Sep 17 00:00:00 2001 From: Simejo Date: Tue, 14 Oct 2025 20:12:16 +0200 Subject: [PATCH 2/2] added workflow to build and public documentation --- .github/workflows/publish-docs.yml | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/publish-docs.yml diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml new file mode 100644 index 0000000..a68cec1 --- /dev/null +++ b/.github/workflows/publish-docs.yml @@ -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 +