QBox_build.yml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. name: QBox_build
  2. on:
  3. workflow_dispatch:
  4. jobs:
  5. build:
  6. runs-on: ubuntu-latest
  7. strategy:
  8. fail-fast: false
  9. matrix:
  10. include:
  11. - userName: q215613905
  12. repoName: TVBoxOS
  13. branchName: main
  14. appName: QBox
  15. osName: qb
  16. steps:
  17. - name: Checkout
  18. uses: actions/checkout@v3
  19. with:
  20. fetch-depth: 0
  21. - name: Check New Commit
  22. run: |
  23. upStream=https://github.com/${{ matrix.userName }}/${{ matrix.repoName }}
  24. echo "upStream=$upStream" >> $GITHUB_ENV
  25. commit=$(curl -sL $upStream/commits/${{ matrix.branchName }} |grep -o "/${{ matrix.userName }}/${{ matrix.repoName }}/commit/[a-z0-9]\+" |head -1 | cut -d\/ -f5)
  26. if ! grep -q "$commit" README.md || [ "${{ inputs.rebuild }}" == "true" ]; then
  27. echo "commit=$commit" >> $GITHUB_ENV
  28. echo "commitS=${commit:0:7}" >> $GITHUB_ENV
  29. fi
  30. - name: Checkout Source Code
  31. if: ${{ env.commit }}
  32. run: |
  33. git clone ${{ env.upStream }} ${{ matrix.repoName }}
  34. cd ${{ matrix.repoName }}
  35. git checkout ${{ env.commit }}
  36. echo "tag=$(git log --date=format:'%Y%m%d-%H%M' --pretty=format:%cd ${{ env.commitS }} -1)" >> $GITHUB_ENV
  37. - name: DIY PY
  38. if: ${{ env.commit }}
  39. working-directory: ${{ matrix.repoName }}
  40. run: |
  41. chmod +x ${{ github.workspace }}/DIY/py.sh
  42. bash ${{ github.workspace }}/DIY/py.sh
  43. - name: DIY
  44. if: ${{ env.commit }}
  45. working-directory: ${{ matrix.repoName }}
  46. run: |
  47. cp -rf $GITHUB_WORKSPACE/DIY/png/图标6.png app/src/main/res/drawable-hdpi/app_icon.png
  48. cp -rf $GITHUB_WORKSPACE/DIY/png/图标6.png app/src/main/res/drawable-xhdpi/app_icon.png
  49. cp -rf $GITHUB_WORKSPACE/DIY/png/图标6.png app/src/main/res/drawable-xxhdpi/app_icon.png
  50. cp -rf $GITHUB_WORKSPACE/DIY/png/图标6.png app/src/main/res/drawable-xxxhdpi/app_icon.png
  51. cp -rf $GITHUB_WORKSPACE/DIY/png/app_bg.png app/src/main/res/drawable/app_bg.png
  52. sed -i 's%播放器 % %g' app/src/main/java/com/github/tvbox/osc/util/PlayerHelper.java
  53. sed -i 's%android:layout_width="@dimen%vs_560"%g' app/src/main/res/values/dimens.xml
  54. sed -i 's%6000%5000%g' app/src/main/java/com/github/tvbox/osc/player/controller/VodController.java
  55. sed -i 's%380+200*spanCount%680+600*spanCount%g' app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java
  56. sed -i 's%spanCount+1%spanCount%g' app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java
  57. sed -i 's%color_BBFFFFFF%color_FFFFFF%g' app/src/main/res/layout/item_home_sort.xml
  58. sed -i 's%color_BBFFFFFF%color_FFFFFF%g' app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java
  59. sed -i 's%com.github.tvbox.osc%com.github.tvbox.osc.${{ matrix.osName }}%g' app/build.gradle
  60. sed -i 's%TVBox%追剧TV%g' app/src/main/res/values/strings.xml
  61. sed -i 's%(HawkConfig.API_URL, "");%(HawkConfig.API_URL, "https://agit.ai/wwz09/ubuntu/raw/branch/master/main.json");%g' app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  62. sed -i 's%Hawk.put(HawkConfig.PLAY_TYPE, 1);%Hawk.put(HawkConfig.HOME_REC, 1); // Home Rec 0=豆瓣, 1=推荐, 2=历史\n Hawk.put(HawkConfig.PLAY_TYPE, 1); // Player 0=系统, 1=IJK, 2=Exo\n Hawk.put(HawkConfig.IJK_CODEC, "硬解码");// IJK Render 软解码, 硬解码\n %g' app/src/main/java/com/github/tvbox/osc/base/App.java
  63. - name: Extra Modify
  64. if: ${{ env.commit }}
  65. working-directory: ${{ matrix.repoName }}
  66. run: |
  67. echo '修改VersionName'
  68. sed -i "/versionName/s#[0-9a-zA-Z_\.\'\"-]\+\$#\'${{ env.tag }}\'#" app/build.gradle
  69. sed -i "/android:text=/s#=\"#=\"${{ env.tag }}\\\\n\\\\n#" app/src/main/res/layout/dialog_about.xml
  70. echo 'crosswalk源,防挂'
  71. if grep -q 'crosswalk' build.gradle; then
  72. sed -i "/crosswalk/a\ maven { url 'https://o0halflife0o.github.io/crosswalk/releases/crosswalk/android/maven2' }" build.gradle
  73. else
  74. sed -i "/jitpack.io/a\ maven { url 'https://o0halflife0o.github.io/crosswalk/releases/crosswalk/android/maven2' }" build.gradle
  75. fi
  76. - name: Option For Test
  77. if: ${{ inputs.testOption }}
  78. working-directory: ${{ matrix.repoName }}
  79. run: |
  80. #添加arm64支持,不支持ijk解码
  81. sed -i "/armeabi-v7a[\'\"]$/s#\$#, 'arm64-v8a'#" app/build.gradle
  82. sed -i "/armeabi-v7a[\'\"]$/s#\$#, 'arm64-v8a'#" player/build.gradle
  83. - name: Release Apk Sign
  84. if: ${{ env.commit }}
  85. working-directory: ${{ matrix.repoName }}
  86. run: |
  87. signingConfigs='ICAgIHNpZ25pbmdDb25maWdzIHtcCiAgICAgICAgaWYgKHByb2plY3QuaGFzUHJvcGVydHkoIlJFTEVBU0VfU1RPUkVfRklMRSIpKSB7XAogICAgICAgICAgICBteUNvbmZpZyB7XAogICAgICAgICAgICAgICAgc3RvcmVGaWxlIGZpbGUoUkVMRUFTRV9TVE9SRV9GSUxFKVwKICAgICAgICAgICAgICAgIHN0b3JlUGFzc3dvcmQgUkVMRUFTRV9TVE9SRV9QQVNTV09SRFwKICAgICAgICAgICAgICAgIGtleUFsaWFzIFJFTEVBU0VfS0VZX0FMSUFTXAogICAgICAgICAgICAgICAga2V5UGFzc3dvcmQgUkVMRUFTRV9LRVlfUEFTU1dPUkRcCiAgICAgICAgICAgICAgICB2MVNpZ25pbmdFbmFibGVkIHRydWVcCiAgICAgICAgICAgICAgICB2MlNpZ25pbmdFbmFibGVkIHRydWVcCiAgICAgICAgICAgICAgICBlbmFibGVWM1NpZ25pbmcgPSB0cnVlXAogICAgICAgICAgICAgICAgZW5hYmxlVjRTaWduaW5nID0gdHJ1ZVwKICAgICAgICAgICAgfVwKICAgICAgICB9XAogICAgfVwKXA=='
  88. signingConfig='ICAgICAgICAgICAgaWYgKHByb2plY3QuaGFzUHJvcGVydHkoIlJFTEVBU0VfU1RPUkVfRklMRSIpKSB7XAogICAgICAgICAgICAgICAgc2lnbmluZ0NvbmZpZyBzaWduaW5nQ29uZmlncy5teUNvbmZpZ1wKICAgICAgICAgICAgfVwK'
  89. signingConfigs="$(echo "$signingConfigs" |base64 -d )"
  90. signingConfig="$(echo "$signingConfig" |base64 -d )"
  91. sed -i -e "/defaultConfig {/i\\$signingConfigs " -e "/debug {/a\\$signingConfig " -e "/release {/a\\$signingConfig " app/build.gradle
  92. cp -f ${{ github.workspace }}/.github/workflows/TVBoxOSC.jks app/TVBoxOSC.jks
  93. sed -i '$a\RELEASE_STORE_FILE=./TVBoxOSC.jks' ./gradle.properties
  94. sed -i '$a\RELEASE_KEY_ALIAS=TVBoxOSC' ./gradle.properties
  95. sed -i '$a\RELEASE_STORE_PASSWORD=TVBoxOSC' ./gradle.properties
  96. sed -i '$a\RELEASE_KEY_PASSWORD=TVBoxOSC' ./gradle.properties
  97. - name: Setup Gradle
  98. if: ${{ env.commit }}
  99. uses: gradle/gradle-build-action@v2
  100. - name: Build With Gradle
  101. if: ${{ env.commit }}
  102. working-directory: ${{ matrix.repoName }}
  103. run: |
  104. chmod +x gradlew
  105. ./gradlew assemblerelease --build-cache --parallel --daemon --warning-mode all
  106. - name: Prepare App
  107. if: ${{ env.commit }}
  108. working-directory: ${{ matrix.repoName }}
  109. run: |
  110. rm -rf apk/
  111. mkdir -p apk/
  112. for file in `find ~ -name "*.apk" -print`; do
  113. mv "$file" apk/${{ matrix.userName }}_${{ matrix.appName }}_${{ env.tag }}.apk
  114. done
  115. - name: Upload App To Artifact
  116. uses: actions/upload-artifact@v3
  117. if: ${{ env.commit }}
  118. with:
  119. name: ${{ matrix.appName }}
  120. path: ${{ matrix.repoName }}/apk/*
  121. - name: Whether Or Not to Publish
  122. if: ${{ inputs.donotpublish && env.commit }}
  123. run: |
  124. echo "commit=" >> $GITHUB_ENV
  125. - name: Release and Upload Assets
  126. uses: ncipollo/release-action@v1
  127. if: ${{ env.commit }}
  128. with:
  129. name: ${{ env.tag }}
  130. tag: ${{ env.tag }}
  131. allowUpdates: true
  132. removeArtifacts: true
  133. artifacts: |
  134. ${{ matrix.repoName }}/apk/*.apk