Update Ditto SDK Versions #17
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: Update Ditto SDK Versions | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "SDK version to update to" | |
| required: true | |
| type: string | |
| default: "4.12.0" | |
| jobs: | |
| update-sdk-versions: | |
| # NOTE: We use macos-latest instead of ubuntu-latest because this workflow needs to run | |
| # CocoaPods commands for updating React Native iOS dependencies. CocoaPods requires a | |
| # macOS environment with Xcode. | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| # Note: react-native-expo uses yarn (not npm), so it's excluded from npm cache paths | |
| cache-dependency-path: | | |
| react-native/package-lock.json | |
| javascript-tui/package-lock.json | |
| javascript-web/package-lock.json | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "9.0.x" | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: "17" | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2.16.0 | |
| with: | |
| channel: "stable" | |
| cache: true | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Setup Ruby and Bundler | |
| uses: ruby/setup-ruby@v1.267.0 | |
| with: | |
| ruby-version: "3.3" | |
| # working-directory specifies where to find Gemfile for bundler-cache | |
| bundler-cache: true | |
| working-directory: react-native | |
| - name: Setup CocoaPods | |
| run: | | |
| sudo gem install cocoapods | |
| pod --version | |
| - name: Update SDK versions and lockfiles | |
| # The Android Kotlin build requires all four Ditto environment variables to be set | |
| # for any Gradle operation (including dependency refresh). These are validated at | |
| # configuration time in android-kotlin/QuickStartTasks/app/build.gradle.kts | |
| env: | |
| DITTO_APP_ID: ${{ secrets.DITTO_APP_ID }} | |
| DITTO_PLAYGROUND_TOKEN: ${{ secrets.DITTO_PLAYGROUND_TOKEN }} | |
| DITTO_AUTH_URL: ${{ secrets.DITTO_AUTH_URL }} | |
| DITTO_WEBSOCKET_URL: ${{ secrets.DITTO_WEBSOCKET_URL }} | |
| run: node scripts/bump-versions.js -t "${{ github.event.inputs.version }}" | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| - name: Create branch and commit changes | |
| id: create-branch | |
| run: | | |
| BRANCH_NAME="sdk-update-${{ github.event.inputs.version }}-$(date +%Y%m%d-%H%M%S)" | |
| echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
| git checkout -b "$BRANCH_NAME" | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| echo "has-changes=false" >> $GITHUB_OUTPUT | |
| else | |
| git commit -m "chore: update Ditto SDK to version ${{ github.event.inputs.version }}" | |
| git push origin "$BRANCH_NAME" | |
| echo "has-changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Draft Pull Request | |
| if: steps.create-branch.outputs.has-changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh pr create \ | |
| --title "chore: update Ditto SDK to version ${{ github.event.inputs.version }}" \ | |
| --body "$(cat <<'EOF' | |
| Updates all quickstart applications to use Ditto SDK version ${{ github.event.inputs.version }} | |
| - Updates lockfiles where possible | |
| - Excludes Kotlin Multiplatform and Java Spring | |
| EOF | |
| )" \ | |
| --draft \ | |
| --head "${{ steps.create-branch.outputs.branch-name }}" \ | |
| --base main | |
| - name: Output PR URL | |
| if: steps.create-branch.outputs.has-changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PR_URL=$(gh pr view "${{ steps.create-branch.outputs.branch-name }}" --json url -q .url) | |
| echo "Created draft PR: $PR_URL" |