feat(intelligence) Add Swift Docs #171
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'intelligence/**/*' | |
| - '.github/workflows/intelligence-*.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'intelligence/**/*' | |
| - '.github/workflows/intelligence-*.yml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| FLWR_TELEMETRY_ENABLED: 0 | |
| jobs: | |
| build_ts_docs: | |
| runs-on: ubuntu-22.04 | |
| name: Build TypeScript Docs | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Bootstrap | |
| uses: ./.github/actions/bootstrap | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '22.14.0' | |
| - name: Install pnpm | |
| run: | | |
| npm install -g pnpm | |
| - name: Install Flower Intelligence | |
| run: | | |
| cd intelligence/ts | |
| pnpm i | |
| - name: Build TS docs | |
| run: | | |
| cd intelligence/ts | |
| pnpm build:docs --readme none --name "TypeScript API" | |
| cd ../.. | |
| - name: Move TS docs | |
| run: | | |
| mkdir -p intelligence/docs/source/ts-api-ref | |
| cp -r intelligence/ts/docs/* intelligence/docs/source/ts-api-ref/ | |
| mv intelligence/docs/source/ts-api-ref/README.md intelligence/docs/source/ts-api-ref/index.md | |
| echo -e '\n```{toctree}\n:hidden:\n:maxdepth: 2\n:glob:\n\n*/*\n```' >> intelligence/docs/source/ts-api-ref/index.md | |
| - name: Upload TS docs artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ts-docs | |
| path: intelligence/docs/source/ts-api-ref/ | |
| build_swift_docs: | |
| runs-on: macos-14 | |
| name: Build Swift Docs | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Bootstrap | |
| uses: ./.github/actions/bootstrap | |
| - uses: swift-actions/setup-swift@v2 | |
| with: | |
| swift-version: "6.0.0" | |
| - uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: "16.2" | |
| - name: Install SourceDocs | |
| run: brew install sourcedocs | |
| - name: Build Swift docs | |
| run: | | |
| sourcedocs generate --module-name FlowerIntelligence -- -scheme flower -destination 'platform=macOS' | |
| mkdir -p intelligence/docs/source/swift-api-ref | |
| cp -r Documentation/Reference/* intelligence/docs/source/swift-api-ref/ | |
| mv intelligence/docs/source/swift-api-ref/README.md intelligence/docs/source/swift-api-ref/index.md | |
| sed -i.bak '1 s/^# .*/# Swift API/' intelligence/docs/source/swift-api-ref/index.md | |
| sed -i.bak '/^This file was generated by/d' intelligence/docs/source/swift-api-ref/index.md | |
| rm -f intelligence/docs/source/swift-api-ref/index.md.bak | |
| echo -e '\n```{toctree}\n:hidden:\n:maxdepth: 2\n:glob:\n\n*/*\n```' >> intelligence/docs/source/swift-api-ref/index.md | |
| - name: Upload Swift docs artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: swift-docs | |
| path: intelligence/docs/source/swift-api-ref/ | |
| build_and_deploy: | |
| runs-on: ubuntu-22.04 | |
| needs: [build_ts_docs, build_swift_docs] | |
| name: Build and Deploy Docs | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Bootstrap | |
| uses: ./.github/actions/bootstrap | |
| - name: Install pandoc | |
| run: sudo apt install pandoc | |
| - name: Install Flower dependencies (mandatory only) | |
| run: python -m poetry install --extras "simulation" | |
| - name: Download TS docs | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ts-docs | |
| path: intelligence/docs/source/ts-api-ref/ | |
| - name: Download Swift docs | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: swift-docs | |
| path: intelligence/docs/source/swift-api-ref/ | |
| - name: Build final docs | |
| run: make html | |
| - name: Deploy docs | |
| if: ${{ github.ref == 'refs/heads/main' && github.repository == 'adap/flower' && !github.event.pull_request.head.repo.fork }} | |
| env: | |
| AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| DOCS_BUCKET: flower.ai | |
| run: | | |
| aws s3 sync --delete --exclude ".*" --exclude "v/*" --cache-control "no-cache" ./intelligence/docs/build/html/ s3://${{ env.DOCS_BUCKET }}/docs/intelligence |