auto_version_dev.yml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # -----------------------------------------------------------------------------
  2. # Workflow: Bump Dev Version
  3. #
  4. # Description:
  5. # This GitHub Actions workflow automatically increments the version number
  6. # defined in `Config.xcconfig` on every push to the `dev` branch.
  7. #
  8. # Versioning Logic:
  9. # - Reads the `LOOP_FOLLOW_MARKETING_VERSION` from `Config.xcconfig`.
  10. # - The version is `MAJOR.MINOR.PATCH` format (3 digits)
  11. # where PATCH is 0 for main branch, each update to dev increments by 1
  12. #
  13. # Example:
  14. # - `2.4.0` for main
  15. # for dev → `2.4.1`, then → `2.4.2`
  16. # - next release (main) will be `2.5.0`
  17. #
  18. # Commit Handling:
  19. # The updated version is then committed and pushed back to the `dev` branch.
  20. # - The bump commit includes the `[skip ci]` tag in its message
  21. # - This prevents the workflow from re-triggering itself in a loop
  22. #
  23. # Prerequisites:
  24. # - `LOOP_FOLLOW_MARKETING_VERSION` must exist and be defined using the format:
  25. # LOOP_FOLLOW_MARKETING_VERSION = x.y.z
  26. # - GitHub Actions bot must have workflow permission to push to `dev`.
  27. # -----------------------------------------------------------------------------
  28. name: zzz [DO NOT RUN] Bump LOOP_FOLLOW_MARKETING_VERSION on dev push
  29. on:
  30. push:
  31. branches:
  32. - dev
  33. jobs:
  34. bump-version:
  35. if: github.repository_owner == 'loopandlearn'
  36. runs-on: ubuntu-latest
  37. steps:
  38. - name: Checkout repository
  39. uses: actions/checkout@v4
  40. with:
  41. token: ${{ secrets.LOOPFOLLOW_TOKEN_AUTOBUMP }}
  42. - name: Set up Git
  43. run: |
  44. git config --global user.name "github-actions[bot]"
  45. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  46. - name: Bump dev version number in Config.xcconfig
  47. run: |
  48. FILE=Config.xcconfig
  49. # Find the line with LOOP_FOLLOW_MARKETING_VERSION and extract the value
  50. VERSION_LINE=$(grep -E '^LOOP_FOLLOW_MARKETING_VERSION *= *[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?' "$FILE")
  51. CURRENT_VERSION=$(echo "$VERSION_LINE" | sed -E 's/^LOOP_FOLLOW_MARKETING_VERSION *= *//')
  52. # Split version into components (up to 3)
  53. IFS='.' read -r MAJOR MINOR FIX <<< "$CURRENT_VERSION"
  54. # Increment FIX
  55. if [ -z "$FIX" ]; then
  56. echo "Error, FIX not found"
  57. else
  58. FIX=$((FIX + 1))
  59. fi
  60. # Construct new version
  61. NEW_VERSION="$MAJOR.$MINOR.$FIX"
  62. echo "New version: $NEW_VERSION"
  63. # Escape dots in current version for sed replacement
  64. ESCAPED_CURRENT_VERSION=$(echo "$CURRENT_VERSION" | sed 's/\./\\./g')
  65. # Replace the LOOP_FOLLOW_MARKETING_VERSION line in-place with new version
  66. if [[ "$OSTYPE" == "darwin"* ]]; then
  67. sed -i '' -E "s/LOOP_FOLLOW_MARKETING_VERSION *= *$ESCAPED_CURRENT_VERSION/LOOP_FOLLOW_MARKETING_VERSION = $NEW_VERSION/" "$FILE"
  68. else
  69. sed -i -E "s/LOOP_FOLLOW_MARKETING_VERSION *= *$ESCAPED_CURRENT_VERSION/LOOP_FOLLOW_MARKETING_VERSION = $NEW_VERSION/" "$FILE"
  70. fi
  71. # Export version so it's available in the next step
  72. echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
  73. - name: Commit and push changes
  74. run: |
  75. git add Config.xcconfig
  76. git commit -m "CI: Bump dev version to $NEW_VERSION [skip ci]"
  77. git push