| name: Roll Dart Dependencies | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| dart_hash: | |
| description: 'The Dart SDK commit hash to update to' | |
| required: true | |
| type: string | |
| jobs: | |
| update-deps: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| repository: flutteractionsbot/flutter | |
| token: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} | |
| ref: master | |
| persist-credentials: false | |
| - name: Configure git | |
| run: | | |
| gh auth setup-git | |
| git config --global user.name "flutteractionsbot" | |
| git config --global user.email "<flutter-actions-bot@google.com>" | |
| env: | |
| GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} | |
| - name: Fetch upstream | |
| run: | | |
| git remote add upstream https://github.com/flutter/flutter.git | |
| git fetch upstream "$REF_NAME" | |
| BRANCH_NAME="sync-dart-$DART_HASH" | |
| echo "BRANCH_NAME=$BRANCH_NAME" >> "$GITHUB_ENV" | |
| git checkout -b "$BRANCH_NAME" "upstream/$REF_NAME" | |
| env: | |
| GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} | |
| REF_NAME: ${{ github.ref_name }} | |
| DART_HASH: ${{ inputs.dart_hash }} | |
| - name: Download and Decode Dart DEPS | |
| id: download-deps | |
| run: | | |
| URL="https://dart.googlesource.com/sdk/+/$DART_HASH/DEPS?format=TEXT" | |
| echo "Fetching DEPS from $URL" | |
| # Googlesource returns base64 encoded text when format=TEXT is used | |
| if ! RESPONSE=$(curl -s -f "$URL"); then | |
| echo "::error::Failed to download DEPS file. Please verify the Dart hash: $DART_HASH" | |
| exit 1 | |
| fi | |
| echo "$RESPONSE" | base64 --decode > dart_deps_file | |
| if [ ! -s dart_deps_file ]; then | |
| echo "::error::Downloaded DEPS file is empty or decoding failed." | |
| exit 1 | |
| fi | |
| env: | |
| DART_HASH: ${{ inputs.dart_hash }} | |
| - name: Run Update Script | |
| id: run-script | |
| run: | | |
| DART_DEPS="dart_deps_file" | |
| FLUTTER_DEPS="DEPS" # Root of the repository | |
| SCRIPT="engine/src/tools/dart/create_updated_flutter_deps.py" | |
| if [ ! -f "$SCRIPT" ]; then | |
| echo "::error::Update script not found at $SCRIPT" | |
| exit 1 | |
| fi | |
| echo "Running $SCRIPT..." | |
| # Execute the python script | |
| if ! python3 "$SCRIPT" -d "$DART_DEPS" -f "$FLUTTER_DEPS" -r "$DART_HASH"; then | |
| echo "::error::The python update script failed during execution." | |
| exit 1 | |
| fi | |
| env: | |
| DART_HASH: ${{ inputs.dart_hash }} | |
| - name: Check for Changes | |
| id: git-check | |
| env: | |
| DART_HASH: ${{ inputs.dart_hash }} | |
| run: | | |
| # Check if the root DEPS file or supports_dart2wasm.js has changed | |
| if git diff --exit-code DEPS engine/src/flutter/lib/web_ui/flutter_js/src/supports_dart2wasm.js; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "## ✅ Dart version already up to date" >> "$GITHUB_STEP_SUMMARY" | |
| echo "The DEPS file is already up to date with Dart hash \`$DART_HASH\`." >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create PR if Changed | |
| if: steps.git-check.outputs.changed == 'true' | |
| run: | | |
| gh auth setup-git | |
| git add DEPS engine/src/flutter/lib/web_ui/flutter_js/src/supports_dart2wasm.js | |
| git commit -m "Update flutter DEPS to dart $DART_HASH" | |
| git push origin "$BRANCH_NAME" --force | |
| PR_URL=$(gh pr create \ | |
| --title "[$REF_NAME] Update Flutter DEPS to Dart $DART_HASH" \ | |
| --body "This PR updates the transitive dependencies in the engine \`DEPS\` file based on Dart SDK hash \`$DART_HASH\`." \ | |
| --repo flutter/flutter \ | |
| --base "$REF_NAME" \ | |
| --head "flutteractionsbot:$BRANCH_NAME") | |
| # Nice big PR Success Summary | |
| { | |
| echo "## 🚀 PR Created Successfully" | |
| echo "Updated dart dependencies to \`$DART_HASH\`." | |
| echo "" | |
| echo "🔗 **View Pull Request:** $PR_URL" | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| env: | |
| GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} | |
| DART_HASH: ${{ inputs.dart_hash }} | |
| REF_NAME: ${{ github.ref_name }} |