TKBox_build.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. name: TKBox_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: pirate888
  12. repoName: TVBoxOSC
  13. branchName: main
  14. appName: TKBox
  15. osName: t9
  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/图标5.png app/src/main/res/drawable/app_icon.png
  48. cp -rf $GITHUB_WORKSPACE/DIY/png/等待图标.png app/src/main/res/drawable/icon_loading.png
  49. cp -rf $GITHUB_WORKSPACE/DIY/qbox/epg_data.json app/src/main/assets/epg_data.json
  50. cp -rf $GITHUB_WORKSPACE/DIY/png/背景3.png app/src/main/res/drawable/app_bg.png
  51. sed -i 's/MM月dd日/yyyy年 MM月 dd日/g' app/src/main/res/values-zh/strings.xml
  52. sed -i 's%TVBox%雷电TV%g' app/src/main/res/values-zh/strings.xml
  53. sed -i 's%com.github.tvbox.osc%com.github.tvbox.osc.${{ matrix.osName }}%g' app/build.gradle
  54. sed -i 's%dd MMM%dd MMM yyyy%g' app/src/main/res/values/strings.xml
  55. sed -i 's%TVBox%雷电TV%g' app/src/main/res/values/strings.xml
  56. sed -i 's%HOME_REC, 2%HOME_REC, 1%g' app/src/main/java/com/github/tvbox/osc/base/App.java
  57. sed -i 's%HomeActivity.getRes().getString(R.string.app_source));% "https://agit.ai/wwz09/ubuntu/raw/branch/master/main.json");%g' app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  58. - name: Extra Modify
  59. if: ${{ env.commit }}
  60. working-directory: ${{ matrix.repoName }}
  61. run: |
  62. echo '修改VersionName'
  63. sed -i "/versionName/s#[0-9a-zA-Z_\.\'\"-]\+\$#\'${{ env.tag }}\'#" app/build.gradle
  64. sed -i "/android:text=/s#=\"#=\"${{ env.tag }}\\\\n\\\\n#" app/src/main/res/layout/dialog_about.xml
  65. echo 'crosswalk源,防挂'
  66. if grep -q 'crosswalk' build.gradle; then
  67. sed -i "/crosswalk/a\ maven { url 'https://o0halflife0o.github.io/crosswalk/releases/crosswalk/android/maven2' }" build.gradle
  68. else
  69. sed -i "/jitpack.io/a\ maven { url 'https://o0halflife0o.github.io/crosswalk/releases/crosswalk/android/maven2' }" build.gradle
  70. fi
  71. - name: Option For Test
  72. if: ${{ inputs.testOption }}
  73. working-directory: ${{ matrix.repoName }}
  74. run: |
  75. #添加arm64支持,不支持ijk解码
  76. sed -i "/armeabi-v7a[\'\"]$/s#\$#, 'arm64-v8a'#" app/build.gradle
  77. sed -i "/armeabi-v7a[\'\"]$/s#\$#, 'arm64-v8a'#" player/build.gradle
  78. - name: Release Apk Sign
  79. if: ${{ env.commit }}
  80. working-directory: ${{ matrix.repoName }}
  81. run: |
  82. signingConfigs='ICAgIHNpZ25pbmdDb25maWdzIHtcCiAgICAgICAgaWYgKHByb2plY3QuaGFzUHJvcGVydHkoIlJFTEVBU0VfU1RPUkVfRklMRSIpKSB7XAogICAgICAgICAgICBteUNvbmZpZyB7XAogICAgICAgICAgICAgICAgc3RvcmVGaWxlIGZpbGUoUkVMRUFTRV9TVE9SRV9GSUxFKVwKICAgICAgICAgICAgICAgIHN0b3JlUGFzc3dvcmQgUkVMRUFTRV9TVE9SRV9QQVNTV09SRFwKICAgICAgICAgICAgICAgIGtleUFsaWFzIFJFTEVBU0VfS0VZX0FMSUFTXAogICAgICAgICAgICAgICAga2V5UGFzc3dvcmQgUkVMRUFTRV9LRVlfUEFTU1dPUkRcCiAgICAgICAgICAgICAgICB2MVNpZ25pbmdFbmFibGVkIHRydWVcCiAgICAgICAgICAgICAgICB2MlNpZ25pbmdFbmFibGVkIHRydWVcCiAgICAgICAgICAgICAgICBlbmFibGVWM1NpZ25pbmcgPSB0cnVlXAogICAgICAgICAgICAgICAgZW5hYmxlVjRTaWduaW5nID0gdHJ1ZVwKICAgICAgICAgICAgfVwKICAgICAgICB9XAogICAgfVwKXA=='
  83. signingConfig='ICAgICAgICAgICAgaWYgKHByb2plY3QuaGFzUHJvcGVydHkoIlJFTEVBU0VfU1RPUkVfRklMRSIpKSB7XAogICAgICAgICAgICAgICAgc2lnbmluZ0NvbmZpZyBzaWduaW5nQ29uZmlncy5teUNvbmZpZ1wKICAgICAgICAgICAgfVwK'
  84. signingConfigs="$(echo "$signingConfigs" |base64 -d )"
  85. signingConfig="$(echo "$signingConfig" |base64 -d )"
  86. sed -i -e "/defaultConfig {/i\\$signingConfigs " -e "/debug {/a\\$signingConfig " -e "/release {/a\\$signingConfig " app/build.gradle
  87. cp -f ${{ github.workspace }}/.github/workflows/TVBoxOSC.jks app/TVBoxOSC.jks
  88. sed -i '$a\RELEASE_STORE_FILE=./TVBoxOSC.jks' ./gradle.properties
  89. sed -i '$a\RELEASE_KEY_ALIAS=TVBoxOSC' ./gradle.properties
  90. sed -i '$a\RELEASE_STORE_PASSWORD=TVBoxOSC' ./gradle.properties
  91. sed -i '$a\RELEASE_KEY_PASSWORD=TVBoxOSC' ./gradle.properties
  92. - name: Setup Gradle
  93. if: ${{ env.commit }}
  94. uses: gradle/gradle-build-action@v2
  95. - name: Build With Gradle
  96. if: ${{ env.commit }}
  97. working-directory: ${{ matrix.repoName }}
  98. run: |
  99. chmod +x gradlew
  100. ./gradlew assemblerelease --build-cache --parallel --daemon --warning-mode all
  101. - name: Prepare App
  102. if: ${{ env.commit }}
  103. working-directory: ${{ matrix.repoName }}
  104. run: |
  105. rm -rf apk/
  106. mkdir -p apk/
  107. for file in `find ~ -name "*.apk" -print`; do
  108. mv "$file" apk/${{ matrix.userName }}_${{ matrix.appName }}_${{ env.tag }}.apk
  109. done
  110. - name: Upload App To Artifact
  111. uses: actions/upload-artifact@v3
  112. if: ${{ env.commit }}
  113. with:
  114. name: ${{ matrix.appName }}
  115. path: ${{ matrix.repoName }}/apk/*
  116. - name: Whether Or Not to Publish
  117. if: ${{ inputs.donotpublish && env.commit }}
  118. run: |
  119. echo "commit=" >> $GITHUB_ENV
  120. - name: Release and Upload Assets
  121. uses: ncipollo/release-action@v1
  122. if: ${{ env.commit }}
  123. with:
  124. name: ${{ env.tag }}
  125. tag: ${{ env.tag }}
  126. allowUpdates: true
  127. removeArtifacts: true
  128. artifacts: |
  129. ${{ matrix.repoName }}/apk/*.apk