#Make `build.zig` generate docs and commit to alternate git branch?

1 messages · Page 1 of 1 (latest)

paper canyon
#

I have an empty branch called docs with just the docs in it for github pages.

Would it be possible to make zig build docs copy/commit the zig-out/docs over to the other branch?

(Switching to the docs branch removes the build.zig file itself.)

#

One alternative would be to just commit zig-out/docs and point github pages to that. But I want other non zig generated html files as well.

mystic parcel
paper canyon
#

Yep.

mystic parcel
#

Oh

#

I have

paper canyon
#

Well, I have a master and a docs on github.

mystic parcel
#

Literally that in my repo lib wait

paper canyon
#

Cool

mystic parcel
#

Just check the build zig, and the ci

paper canyon
#

Thanks for sharing! Checking it out now.

mystic parcel
#

The lib can emit the docs and in the CI it deploys them

#

You would have to switch from the github pages to deploy from actions instead of branch

paper canyon
#

Interesting. Yea I was hoping to do it without needing github actions. i.e.

  • build.zig generates the docs,
  • build.zigputs zig-out/docs into the docs git branch.
  • build.zig does git commit and git push with the docs branch

(That way it doesnt have to be github.)

mystic parcel
#

Oh well

#

You could, I just find it easier

#

You just need to copy the docs dir from zig-out/docs into the whole branch, which I used to have a repo like that but think migrated it to actions too

paper canyon
#

Yea, I could do it with github actions. They just don't always work for me.

#

Like right now, I have a few failing repos because the apt-get fails to get ffmpeg for the past few days.

#

I'll do it your way if I cant find another way.

mystic parcel
#

Hmm I was gonna say submodules, but an option in your case would be git work trees? Probably

#

Create the empty docs branch and have it within zig out and make the build docs copy paste it there etc.

paper canyon
#

I also just had another idea. "git clone docs branch into a temp folder and copy the zig-out/docs into it"

mystic parcel
#

Oh well xd

paper canyon
#

Just reading up on git worktree.

To instead work on an existing branch in a new worktree, use git worktree add <path> <branch>.

It does seem like you could clear zig-out/docs and "worktree" a docs branch into it. Thats neat. Ive never used it before though.

boreal geode
#

note: you can install files into alternate install prefixes using -p/--prefix

atomic pumice
#

Switching to the docs branch removes the build.zig file itself

This is kind of sketchy, but the compiled build script is actually located in .zig-cache, so as long as that is not tracked by git, it should still be present if you switch branches out from underneath yourself (as well as zig-out docs would be copied from .zig-cache too)