version.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. set -e
  3. VERSION_CODE=800800
  4. VERSION_NAME=0.8.8
  5. VERSION_TARGET=$1
  6. do_version_readme() {
  7. # README.md
  8. # cat README.md \
  9. # | sed "s/\(#compile 'tv.danmaku.ijk.media:ijkplayer-java:#\)[[:digit:]][[:digit:].]*\(#'#\)/\1:$VERSION_NAME\2/" \
  10. # > README.md.new
  11. cat README.md \
  12. | sed "s/\(compile \'tv.danmaku.ijk.media:ijkplayer-[[:alnum:]_]*:\)[[:digit:].]*[[:digit:]]/\1$VERSION_NAME/g" \
  13. | sed "s/\(git checkout -B latest k\)[[:digit:]][[:digit:].]*/\1$VERSION_NAME/g" \
  14. > README.md.new
  15. mv -f README.md.new README.md
  16. }
  17. do_version_gradle() {
  18. # android/ijkplayer/build.gradle
  19. cat android/ijkplayer/build.gradle \
  20. | sed "s/\(versionCode[[:space:]]*=[[:space:]]*\)[[:digit:]][[:digit:]]*/\1$VERSION_CODE/" \
  21. | sed "s/\(versionName[[:space:]]*=[[:space:]]*\)\"[[:digit:].]*[[:digit:]]\"/\1\"$VERSION_NAME\"/" \
  22. > android/ijkplayer/build.gradle.new
  23. mv -f android/ijkplayer/build.gradle.new android/ijkplayer/build.gradle
  24. # android/ijkplayer/gradle.properties
  25. cat android/ijkplayer/gradle.properties \
  26. | sed "s/\(VERSION_NAME=\)[[:digit:].]*[[:digit:]]/\1$VERSION_NAME/" \
  27. | sed "s/\(VERSION_CODE=\)[[:digit:]][[:digit:]]*/\1$VERSION_CODE/" \
  28. > android/ijkplayer/gradle.properties.new
  29. mv -f android/ijkplayer/gradle.properties.new android/ijkplayer/gradle.properties
  30. # android/ijkplayer/ijkplayer-exo/build.gradle
  31. cat android/ijkplayer/ijkplayer-exo/build.gradle \
  32. | sed "s/\(compile \'tv.danmaku.ijk.media:ijkplayer-[-_[:alpha:][:digit:]]*:\)[[:digit:].]*[[:digit:]]/\1$VERSION_NAME/g" \
  33. > android/ijkplayer/ijkplayer-exo/build.gradle.new
  34. mv -f android/ijkplayer/ijkplayer-exo/build.gradle.new android/ijkplayer/ijkplayer-exo/build.gradle
  35. # android/ijkplayer/ijkplayer-example/build.gradle
  36. cat android/ijkplayer/ijkplayer-example/build.gradle \
  37. | sed "s/\(ompile \'tv.danmaku.ijk.media:ijkplayer-[-_[:alpha:][:digit:]]*:\)[[:digit:].]*[[:digit:]]/\1$VERSION_NAME/g" \
  38. > android/ijkplayer/ijkplayer-example/build.gradle.new
  39. mv -f android/ijkplayer/ijkplayer-example/build.gradle.new android/ijkplayer/ijkplayer-example/build.gradle
  40. }
  41. do_version_xcode() {
  42. # ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj
  43. cat ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj \
  44. | sed "s/\(CURRENT_PROJECT_VERSION = \).*;/\1$VERSION_NAME;/g" \
  45. > ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj.new
  46. mv -f ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj.new ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj
  47. }
  48. if [ "$VERSION_TARGET" = "readme" ]; then
  49. do_version_readme
  50. elif [ "$VERSION_TARGET" = "gradle" ]; then
  51. do_version_gradle
  52. elif [ "$VERSION_TARGET" = "show" ]; then
  53. echo $VERSION_NAME
  54. elif [ "$VERSION_TARGET" = "xcode" ]; then
  55. do_version_xcode
  56. else
  57. do_version_readme
  58. do_version_gradle
  59. do_version_xcode
  60. fi