update-cpp-sdk-on-release.yml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Whenever a new Firebase iOS SDK is released, this workflow triggers *another*
  2. # workflow on the Firebase C++ SDK, which will check for the iOS version update
  3. # and create a PR updating its iOS dependencies if the version number has
  4. # changed.
  5. name: update-cpp-sdk-on-release
  6. on:
  7. release:
  8. types: [ published ]
  9. concurrency:
  10. group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  11. cancel-in-progress: true
  12. jobs:
  13. trigger_cpp_sdk_update:
  14. # Only when a new release (not just the CocoaPods-* tag) is published.
  15. if: ${{ (github.event_name == 'release' && !contains(github.ref, 'CocoaPods')) }}
  16. # Fetch an authentication token for firebase-workflow-trigger, then use that
  17. # token to trigger the update-dependencies workflow in firebase-cpp-sdk.
  18. name: Trigger C++ SDK update
  19. runs-on: ubuntu-latest
  20. steps:
  21. - name: Setup python
  22. uses: actions/setup-python@v2
  23. with:
  24. python-version: 3.7
  25. - name: Check out firebase-cpp-sdk
  26. uses: actions/checkout@v2.3.1
  27. with:
  28. repository: firebase/firebase-cpp-sdk
  29. ref: main
  30. - name: Get firebase-workflow-trigger token
  31. uses: tibdex/github-app-token@v1
  32. id: generate-token
  33. with:
  34. app_id: ${{ secrets.CPP_WORKFLOW_TRIGGER_APP_ID }}
  35. private_key: ${{ secrets.CPP_WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
  36. repository: firebase/firebase-cpp-sdk
  37. - name: Ensure Cocoapods repo has been updated
  38. run: |
  39. # If the new version is simply vX.Y.Z, wait up to an hour for its podspec to be present.
  40. if [[ "$GITHUB_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
  41. echo "Checking Cocoapods repo for associated Firebase ${GITHUB_REF:1} podspec."
  42. podspec_url="https://github.com/CocoaPods/Specs/blob/master/Specs/0/3/5/Firebase/${GITHUB_REF:1}/Firebase.podspec.json"
  43. for retry in {1..12} error; do
  44. # Check every 5 minutes, up to an hour, for the new podspec to be present.
  45. # If it's still not present, trigger the update anyway.
  46. if [[ $retry == "error" ]]; then
  47. echo "::warning ::Firebase ${GITHUB_REF:1} podspec not found, updating anyway."
  48. exit 0
  49. fi
  50. echo -n "Check ${podspec_url} (attempt ${retry}) ..."
  51. curl -L -f -o /dev/null "${podspec_url}" 2> /dev/null && echo " success!" && break
  52. echo " failed."
  53. sleep 300
  54. done
  55. else
  56. echo "Tag '$GITHUB_REF' doesn't match the 'vX.Y.Z' format, skipping Cocoapods repo check."
  57. fi
  58. - name: Trigger firebase-cpp-sdk update
  59. run: |
  60. pip install -r scripts/gha/requirements.txt
  61. python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} -w update-dependencies.yml -p updateAndroid 0 -p updateiOS 1 -p comment "[Triggered]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) by [firebase-ios-sdk $GITHUB_REF release]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$GITHUB_REF)." -s 10 -A