~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/zat

atproto utils for zig · mirror of https://tangled.org/zat.dev/zat

0
0
62 lines · 2.0 KB Raw History
# branch pushes publish only when the docs, devlog or publish tooling change
# (the same list the publish step checks); tag pushes always publish.
when:
  - event: ["push"]
    branch: ["main"]
    paths: [README.md, CHANGELOG.md, "docs/**", "devlog/**", "examples/*.md", scripts/publish-docs.zig, .tangled/workflows/publish-standard-records.yml]
  - event: ["push"]
    tag: ["v*"]

engine: nixery

clone:
  depth: 50

dependencies:
  nixpkgs:
    - coreutils
    - curl
    - git
    - gnutar
    - xz

steps:
  - name: install pinned zig
    command: scripts/ci-zig.sh /tangled/workspace/.zig

  - name: fetch dependencies
    command: |
      # tangled.org rate-limits archive downloads; three workflows fetching at
      # once on every push has tripped it. retry with backoff before building.
      ok=0
      for attempt in 1 2 3 4 5; do
        if /tangled/workspace/.zig/zig build --fetch; then ok=1; break; fi
        echo "dependency fetch attempt $attempt failed; retrying" >&2
        sleep $((attempt * 15))
      done
      [ "$ok" = 1 ]

  - name: build and publish docs to ATProto
    command: |
      set -e
      # branch pushes publish only when docs, devlog, or the publish tooling
      # changed; tag pushes always publish. pure shell — grep is not in the image.
      if [ "${TANGLED_REF#refs/tags/}" = "$TANGLED_REF" ]; then
        publish=0
        for f in $(git diff-tree --no-commit-id --name-only -r HEAD); do
          case "$f" in
            README.md|CHANGELOG.md|docs/*|devlog/*|examples/*.md|scripts/publish-docs.zig|.tangled/workflows/publish-standard-records.yml)
              publish=1 ;;
          esac
        done
        if [ "$publish" -eq 0 ]; then
          echo "no docs/devlog changes; skipping ATProto docs publish"
          exit 0
        fi
      fi
      if [ -z "$ATPROTO_PASSWORD" ]; then
        echo "ATPROTO_PASSWORD is not set; cannot publish docs" >&2
        exit 1
      fi
      /tangled/workspace/.zig/zig build
      ./zig-out/bin/publish-docs