TVBox_test_T.yml 6.6 KB

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