Skip to content

Commit

Permalink
📝 generate docs and deploy in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelStark committed Sep 2, 2024
1 parent b4bca69 commit 19e3964
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [main]

env:
ZIG_VERSION: 0.14.0-dev.1402+cad65307b
ZIG_VERSION: 0.14.0-dev.1409+6d2945f1f

jobs:
build:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Generate and Deploy Docs

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

permissions: write-all

env:
ZIG_VERSION: 0.14.0-dev.1409+6d2945f1f

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Cache Zig
uses: actions/cache@v3
with:
path: ~/zig
key: ${{ runner.os }}-zig-${{ env.ZIG_VERSION }}

- name: Install Zig
if: steps.cache.outputs.cache-hit != 'true'
run: |
wget https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz
tar -xf zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz
mv zig-linux-x86_64-${{ env.ZIG_VERSION }} ~/zig
- name: Add Zig to PATH
run: echo "${HOME}/zig" >> $GITHUB_PATH

- name: Cache Zig build artifacts
uses: actions/cache@v3
with:
path: |
zig-cache
~/.cache/zig
key: ${{ runner.os }}-zig-build-${{ hashFiles('**/*.zig') }}
restore-keys: |
${{ runner.os }}-zig-build-
- name: Build Docs
run: zig build docs

- name: Deploy
if: ${{ github.ref == 'refs/heads/main' }} && steps.check_changes.outcome == 'success'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: zig-out/docs
10 changes: 10 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,14 @@ pub fn build(b: *std.Build) !void {

const bench_step = b.step("bench", "Run benchmarks");
bench_step.dependOn(&run_bench.step);

// Add documentation generation step
const install_docs = b.addInstallDirectory(.{
.source_dir = lib.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});

const docs_step = b.step("docs", "Generate documentation");
docs_step.dependOn(&install_docs.step);
}

0 comments on commit 19e3964

Please sign in to comment.