Docs #36
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: | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: ["Publish"] | |
| types: [completed] | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build-shared: | |
| # For workflow_run triggers, only proceed on successful publish | |
| if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' | |
| uses: ./.github/workflows/_build-shared.yml | |
| secrets: inherit | |
| generate-android-docs: | |
| name: Generate Android Docs | |
| runs-on: macos-latest | |
| needs: build-shared | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| distribution: zulu | |
| java-version: 17 | |
| cache: gradle | |
| - name: Download SwiftUtils interop artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: swift-utils-interop | |
| path: source/shared/sdk/shared/src/iosMain/interop/ | |
| - name: Download StytchSharedSDK xcframework | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: shared-xcframework | |
| path: source/shared/sdk/shared/build/XCFrameworks/release/StytchSharedSDK.xcframework | |
| - name: Restore shared mavenLocal artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: shared-maven-local | |
| path: ~/.m2/repository/com/stytch/sdk/ | |
| - name: Generate Dokka docs | |
| working-directory: source/sdks | |
| run: ./gradlew dokkaGenerateHtml | |
| - name: Upload Android docs artifact | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: android-docs | |
| path: source/sdks/build/dokka/html/ | |
| generate-ios-docs: | |
| name: Generate iOS Docs | |
| runs-on: macos-latest | |
| needs: build-shared | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| distribution: zulu | |
| java-version: 17 | |
| cache: gradle | |
| - name: Download SwiftUtils interop artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: swift-utils-interop | |
| path: source/shared/sdk/shared/src/iosMain/interop/ | |
| - name: Download StytchSharedSDK xcframework | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: shared-xcframework | |
| path: source/shared/sdk/shared/build/XCFrameworks/release/StytchSharedSDK.xcframework | |
| - name: Restore shared mavenLocal artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: shared-maven-local | |
| path: ~/.m2/repository/com/stytch/sdk/ | |
| - name: Build Consumer and B2B ios-arm64 frameworks | |
| working-directory: source/sdks | |
| run: ./gradlew :sdk:consumer-headless:linkReleaseFrameworkIosArm64 :sdk:b2b-headless:linkReleaseFrameworkIosArm64 | |
| - name: Copy frameworks to source/ios | |
| run: | | |
| mkdir -p source/ios/StytchConsumerSDK.xcframework/ios-arm64 | |
| cp -r source/sdks/sdk/consumer-headless/build/bin/iosArm64/releaseFramework/StytchConsumerSDK.framework \ | |
| source/ios/StytchConsumerSDK.xcframework/ios-arm64/ | |
| mkdir -p source/ios/StytchB2BSDK.xcframework/ios-arm64 | |
| cp -r source/sdks/sdk/b2b-headless/build/bin/iosArm64/releaseFramework/StytchB2BSDK.framework \ | |
| source/ios/StytchB2BSDK.xcframework/ios-arm64/ | |
| cp -r source/shared/sdk/shared/build/XCFrameworks/release/StytchSharedSDK.xcframework source/ios/ | |
| cp -r source/shared/sdk/shared/src/iosMain/interop/StytchSwiftUtils.xcframework source/ios/ | |
| - name: Extract symbol graphs | |
| run: | | |
| SDK=$(xcrun --sdk iphoneos --show-sdk-path) | |
| mkdir -p symbolgraphs/consumer symbolgraphs/consumer-injected | |
| xcrun swift-symbolgraph-extract \ | |
| -sdk "$SDK" \ | |
| -target arm64-apple-ios15.0 \ | |
| -module-name StytchConsumerSDK \ | |
| -F source/ios/StytchConsumerSDK.xcframework/ios-arm64 \ | |
| -F source/ios/StytchSharedSDK.xcframework/ios-arm64 \ | |
| -F source/ios/StytchSwiftUtils.xcframework/ios-arm64 \ | |
| -minimum-access-level public \ | |
| -output-dir symbolgraphs/consumer | |
| mkdir -p symbolgraphs/b2b symbolgraphs/b2b-injected | |
| xcrun swift-symbolgraph-extract \ | |
| -sdk "$SDK" \ | |
| -target arm64-apple-ios15.0 \ | |
| -module-name StytchB2BSDK \ | |
| -F source/ios/StytchB2BSDK.xcframework/ios-arm64 \ | |
| -F source/ios/StytchSharedSDK.xcframework/ios-arm64 \ | |
| -F source/ios/StytchSwiftUtils.xcframework/ios-arm64 \ | |
| -minimum-access-level public \ | |
| -output-dir symbolgraphs/b2b | |
| - name: Filter internal symbols from symbol graphs | |
| run: | | |
| python3 scripts/filter-symbols.py \ | |
| symbolgraphs/consumer/StytchConsumerSDK.symbols.json \ | |
| symbolgraphs/consumer/StytchConsumerSDK.symbols.json | |
| python3 scripts/filter-symbols.py \ | |
| symbolgraphs/b2b/StytchB2BSDK.symbols.json \ | |
| symbolgraphs/b2b/StytchB2BSDK.symbols.json | |
| - name: Inject KDocs into symbol graphs | |
| run: | | |
| python3 scripts/inject-docs.py \ | |
| source/ios/StytchConsumerSDK.xcframework/ios-arm64/StytchConsumerSDK.framework/Headers/StytchConsumerSDK.h \ | |
| symbolgraphs/consumer/StytchConsumerSDK.symbols.json \ | |
| symbolgraphs/consumer-injected/StytchConsumerSDK.symbols.json | |
| cp symbolgraphs/consumer/StytchConsumerSDK@Foundation.symbols.json symbolgraphs/consumer-injected/ | |
| cp symbolgraphs/consumer/StytchConsumerSDK@Swift.symbols.json symbolgraphs/consumer-injected/ | |
| python3 scripts/inject-docs.py \ | |
| source/ios/StytchB2BSDK.xcframework/ios-arm64/StytchB2BSDK.framework/Headers/StytchB2BSDK.h \ | |
| symbolgraphs/b2b/StytchB2BSDK.symbols.json \ | |
| symbolgraphs/b2b-injected/StytchB2BSDK.symbols.json | |
| cp symbolgraphs/b2b/StytchB2BSDK@Foundation.symbols.json symbolgraphs/b2b-injected/ | |
| cp symbolgraphs/b2b/StytchB2BSDK@Swift.symbols.json symbolgraphs/b2b-injected/ | |
| - name: Convert to static DocC sites | |
| run: | | |
| mkdir -p docs-output/ios/consumer | |
| mkdir -p docs-output/ios/b2b | |
| xcrun docc convert source/ios/docs/StytchConsumerSDK.docc \ | |
| --additional-symbol-graph-dir symbolgraphs/consumer-injected \ | |
| --transform-for-static-hosting \ | |
| --hosting-base-path stytch-mobile/ios/consumer \ | |
| --output-dir docs-output/ios/consumer | |
| xcrun docc convert source/ios/docs/StytchB2BSDK.docc \ | |
| --additional-symbol-graph-dir symbolgraphs/b2b-injected \ | |
| --transform-for-static-hosting \ | |
| --hosting-base-path stytch-mobile/ios/b2b \ | |
| --output-dir docs-output/ios/b2b | |
| - name: Tar iOS docs (avoid colon-in-filename rejection by upload-artifact) | |
| run: tar -czf ios-docs.tar.gz -C docs-output/ios . | |
| - name: Upload iOS docs artifact | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: ios-docs | |
| path: ios-docs.tar.gz | |
| update-mintlify-docs: | |
| name: Update Mintlify Docs | |
| runs-on: ubuntu-latest | |
| needs: build-shared | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| distribution: zulu | |
| java-version: 17 | |
| cache: gradle | |
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: "3.12" | |
| - name: Restore shared mavenLocal artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: shared-maven-local | |
| path: ~/.m2/repository/com/stytch/sdk/ | |
| - name: Generate Mintlify docs (consumer + b2b) | |
| working-directory: source/sdks | |
| run: | | |
| ./gradlew \ | |
| :sdk:consumer-headless:generateMintlifyDocs \ | |
| :sdk:b2b-headless:generateMintlifyDocs | |
| - name: Check out mintlify-docs | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| repository: stytchauth/mintlify-docs | |
| token: ${{ secrets.MINTLIFY_DOCS_TOKEN }} | |
| path: mintlify-docs | |
| - name: Switch to kmp-docs-update branch | |
| working-directory: mintlify-docs | |
| run: | | |
| git fetch origin kmp-docs-update || true | |
| git checkout kmp-docs-update 2>/dev/null || git checkout -b kmp-docs-update | |
| - name: Copy MDX files and update docs.json | |
| run: | | |
| python3 scripts/update-mobile-docs.py \ | |
| --consumer-output source/sdks/sdk/consumer-headless/build/mintlify \ | |
| --b2b-output source/sdks/sdk/b2b-headless/build/mintlify \ | |
| --docs-repo mintlify-docs | |
| - name: Check for changes | |
| id: check-changes | |
| working-directory: mintlify-docs | |
| run: | | |
| git diff --quiet && git diff --cached --quiet && \ | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" || \ | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| if: steps.check-changes.outputs.has_changes == 'true' | |
| with: | |
| node-version: "22" | |
| - name: Lint MDX files | |
| if: steps.check-changes.outputs.has_changes == 'true' | |
| working-directory: mintlify-docs | |
| run: npm ci && npm run lint | |
| - name: Commit and push changes | |
| if: steps.check-changes.outputs.has_changes == 'true' | |
| working-directory: mintlify-docs | |
| run: | | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git add -A | |
| git commit -m "chore: update mobile SDK docs" | |
| git push origin kmp-docs-update | |
| - name: Open or update PR in mintlify-docs | |
| if: steps.check-changes.outputs.has_changes == 'true' | |
| working-directory: mintlify-docs | |
| env: | |
| GH_TOKEN: ${{ secrets.MINTLIFY_DOCS_TOKEN }} | |
| run: | | |
| PR_COUNT=$(gh pr list --repo stytchauth/mintlify-docs --head kmp-docs-update --json number --jq 'length') | |
| if [ "$PR_COUNT" -gt 0 ]; then | |
| echo "PR already exists, no action needed" | |
| else | |
| gh pr create \ | |
| --repo stytchauth/mintlify-docs \ | |
| --head kmp-docs-update \ | |
| --base main \ | |
| --title "chore: update mobile SDK docs" \ | |
| --reviewer stytchauth/frontend \ | |
| --body "Auto-generated from KDoc comments in [stytchauth/stytch-mobile](https://github.com/stytchauth/stytch-mobile). | |
| Updates method reference pages for Android, iOS, and React Native across both Consumer and B2B SDKs." | |
| fi | |
| deploy-pages: | |
| name: Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| needs: [generate-android-docs, generate-ios-docs] | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Download Android docs | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: android-docs | |
| path: pages/android/ | |
| - name: Download iOS docs | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ios-docs | |
| path: . | |
| - name: Untar iOS docs | |
| run: mkdir -p pages/ios && tar -xzf ios-docs.tar.gz -C pages/ios | |
| - name: Copy landing page | |
| run: cp docs/* pages/ | |
| - name: Configure Pages | |
| uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 | |
| with: | |
| path: pages/ | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 |