Skip to content

feat: add support for event functions #92

feat: add support for event functions

feat: add support for event functions #92

Workflow file for this run

name: Generate and upload TypeDoc to Sanity Docs API
on:
# Generate and upload TypeDoc on releases
push:
tags:
- "v*"
# Validate TypeDoc generation on PRs
pull_request:
paths:
- "src/**"
- "package.json"
- "README.md"
- ".github/workflows/upload-typedoc.yml"
# Manual trigger
workflow_dispatch:
inputs:
upload:
description: Upload generated TypeDoc file
required: false
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
generate-typedoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: lts/*
- name: Install project dependencies
run: npm ci
- name: Generate TypeDoc
id: generate
run: |
echo "🔄 Generating TypeDoc documentation..."
npm run docs:typedoc
# Check if the file was generated successfully
if [ -f "docs/typedoc-output.json" ]; then
FILE_SIZE=$(du -h docs/typedoc-output.json | cut -f1)
EXPORT_COUNT=$(jq '[.children[]?.children // empty | length] | add // 0' docs/typedoc-output.json)
echo "✅ TypeDoc generated successfully"
echo "📄 File size: $FILE_SIZE"
echo "📊 Total exports: $EXPORT_COUNT"
echo "file_size=$FILE_SIZE" >> $GITHUB_OUTPUT
echo "export_count=$EXPORT_COUNT" >> $GITHUB_OUTPUT
echo "success=true" >> $GITHUB_OUTPUT
else
echo "❌ TypeDoc file was not generated"
echo "success=false" >> $GITHUB_OUTPUT
exit 1
fi
- name: Upload TypeDoc artifact
if: steps.generate.outputs.success == 'true'
uses: actions/upload-artifact@v7
with:
name: typedoc-${{ github.sha }}
path: docs/typedoc-output.json
retention-days: 1
- name: Upload HTML docs artifact
if: github.event_name == 'pull_request' && steps.generate.outputs.success == 'true'
id: html-artifact
uses: actions/upload-artifact@v7
with:
name: typedoc-html-pr-${{ github.event.pull_request.number }}
path: docs/html
retention-days: 7
- name: Comment on PR
if: github.event_name == 'pull_request' && steps.generate.outputs.success == 'true'
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3
with:
comment-tag: "typedoc-result"
message: |
## 📚 TypeDoc Generation Result
✅ **TypeDoc generated successfully!**
- **File size:** ${{ steps.generate.outputs.file_size }}
- **Total exports:** ${{ steps.generate.outputs.export_count }}
- **Artifact:** `typedoc-${{ github.sha }}`
- **HTML docs preview:** [Download artifact](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.html-artifact.outputs.artifact-id }})
The TypeDoc JSON file has been generated and validated. All documentation scripts completed successfully.
- name: Extract version from tag
if: (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.upload == 'true') && steps.generate.outputs.success == 'true'
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
# Extract version from git tag (e.g., refs/tags/v1.2.3 -> 1.2.3)
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "📋 Extracted version from tag: $VERSION"
else
# For manual dispatch, get version from package.json
VERSION=$(jq -r .version package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "📋 Using package.json version: $VERSION"
fi
- name: Upload TypeDoc to Sanity Docs API
if: (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.upload == 'true') && steps.generate.outputs.success == 'true'
uses: sanity-io/reference-api-typedoc/.github/actions/typedoc-upload@main
with:
packageName: "@sanity/blueprints"
version: ${{ steps.version.outputs.version }}
typedocJsonPath: "docs/typedoc-output.json"
env:
SANITY_DOCS_API_TOKEN: ${{ secrets.SANITY_DOCS_API_TOKEN }}