release_tuic.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. name: TUIC Plugin Release Build
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. tag:
  6. description: 'Release Tag'
  7. required: true
  8. upload:
  9. description: 'Upload: If want ignore'
  10. required: false
  11. publish:
  12. description: 'Publish: If want ignore'
  13. required: false
  14. play:
  15. description: 'Play: If want ignore'
  16. required: false
  17. jobs:
  18. check:
  19. name: Check Access
  20. runs-on: ubuntu-latest
  21. steps:
  22. - name: "Check access"
  23. uses: "lannonbr/[email protected]"
  24. with:
  25. permission: "write"
  26. env:
  27. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  28. native:
  29. name: Native Build
  30. runs-on: ubuntu-latest
  31. steps:
  32. - name: Checkout
  33. uses: actions/checkout@v3
  34. - name: Fetch Status
  35. run: git submodule status 'plugin/tuic/*' > tuic_status
  36. - name: TUIC Cache
  37. id: cache
  38. uses: actions/cache@v3
  39. with:
  40. path: |
  41. plugin/tuic/src/main/jniLibs
  42. key: ${{ hashFiles('.github/workflows/*', 'bin/lib/tuic/*', 'tuic_status') }}
  43. - name: Gradle cache
  44. uses: actions/cache@v3
  45. with:
  46. path: ~/.gradle
  47. key: gradle-${{ hashFiles('**/*.gradle.kts') }}
  48. - name: Install toolchain
  49. run: |
  50. rustup toolchain install stable
  51. rustup override set stable
  52. if: steps.cache.outputs.cache-hit != 'true'
  53. - name: Install rust android target
  54. run: ./run init action rust
  55. if: steps.cache.outputs.cache-hit != 'true'
  56. - name: Native Build
  57. if: steps.cache.outputs.cache-hit != 'true'
  58. run: ./run plugin tuic
  59. build:
  60. name: Gradle Build
  61. runs-on: ubuntu-latest
  62. needs:
  63. - native
  64. - check
  65. steps:
  66. - name: Checkout
  67. uses: actions/checkout@v3
  68. - name: Fetch Status
  69. run: git submodule status 'plugin/tuic/*' > tuic_status
  70. - name: TUIC Cache
  71. uses: actions/cache@v3
  72. with:
  73. path: |
  74. plugin/tuic/src/main/jniLibs
  75. key: ${{ hashFiles('.github/workflows/*', 'bin/lib/tuic/*', 'tuic_status') }}
  76. - name: Gradle cache
  77. uses: actions/cache@v3
  78. with:
  79. path: ~/.gradle
  80. key: gradle-${{ hashFiles('**/*.gradle.kts') }}
  81. - name: Release Build
  82. env:
  83. SKIP_BUILD: on
  84. BUILD_PLUGIN: tuic
  85. run: |
  86. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  87. echo "ndk.dir=${ANDROID_HOME}/ndk/25.0.8775105" >> local.properties
  88. export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
  89. ./run init action library
  90. ./gradlew :plugin:tuic:assembleOssRelease
  91. APK=$(find plugin/tuic/build/outputs/apk -name '*arm64-v8a*.apk')
  92. APK=$(dirname "$APK")
  93. echo "APK=$APK" >> $GITHUB_ENV
  94. - uses: actions/upload-artifact@v3
  95. with:
  96. name: APKs
  97. path: ${{ env.APK }}
  98. - uses: actions/upload-artifact@v3
  99. with:
  100. name: "SHA256-ARM ${{ env.SHA256_ARM }}"
  101. path: ${{ env.SUM_ARM }}
  102. - uses: actions/upload-artifact@v3
  103. with:
  104. name: "SHA256-ARM64 ${{ env.SHA256_ARM64 }}"
  105. path: ${{ env.SUM_ARM64 }}
  106. - uses: actions/upload-artifact@v3
  107. with:
  108. name: "SHA256-X64 ${{ env.SHA256_X64 }}"
  109. path: ${{ env.SUM_X64 }}
  110. - uses: actions/upload-artifact@v3
  111. with:
  112. name: "SHA256-X86 ${{ env.SHA256_X86 }}"
  113. path: ${{ env.SUM_X86 }}
  114. publish:
  115. name: Publish Release
  116. if: github.event.inputs.publish != 'y'
  117. runs-on: ubuntu-latest
  118. needs: build
  119. steps:
  120. - name: Checkout
  121. uses: actions/checkout@v3
  122. - name: Donwload Artifacts
  123. uses: actions/download-artifact@v3
  124. with:
  125. name: APKs
  126. path: artifacts
  127. - name: Release
  128. run: |
  129. wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
  130. tar -xvf ghr.tar.gz
  131. mv ghr*linux_amd64/ghr .
  132. mkdir apks
  133. find artifacts -name "*.apk" -exec cp {} apks \;
  134. find artifacts -name "*.sha256sum.txt" -exec cp {} apks \;
  135. ./ghr -delete -prerelease -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks
  136. upload:
  137. name: Upload Release
  138. if: github.event.inputs.upload != 'y'
  139. runs-on: ubuntu-latest
  140. needs: build
  141. steps:
  142. - name: Donwload Artifacts
  143. uses: actions/download-artifact@v3
  144. with:
  145. name: APKs
  146. path: artifacts
  147. - name: Release
  148. run: |
  149. mkdir apks
  150. find artifacts -name "*.apk" -exec cp {} apks \;
  151. function upload() {
  152. for apk in $@; do
  153. echo ">> Uploading $apk"
  154. curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \
  155. -X POST \
  156. -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \
  157. -F document="@$apk" \
  158. --silent --show-error --fail >/dev/null &
  159. done
  160. for job in $(jobs -p); do
  161. wait $job || exit 1
  162. done
  163. }
  164. upload apks/*
  165. play:
  166. name: Publish to Play Store
  167. if: github.event.inputs.play != 'y'
  168. runs-on: ubuntu-latest
  169. needs:
  170. - native
  171. - check
  172. steps:
  173. - name: Checkout
  174. uses: actions/checkout@v3
  175. - name: Fetch Status
  176. run: git submodule status 'plugin/tuic/*' > tuic_status
  177. - name: Hysteria Cache
  178. uses: actions/cache@v3
  179. with:
  180. path: |
  181. plugin/tuic/src/main/jniLibs
  182. key: ${{ hashFiles('.github/workflows/*', 'bin/lib/tuic/*', 'tuic_status') }}
  183. - name: Gradle cache
  184. uses: actions/cache@v3
  185. with:
  186. path: ~/.gradle
  187. key: gradle-${{ hashFiles('**/*.gradle.kts') }}
  188. - name: Release Build
  189. env:
  190. SKIP_BUILD: on
  191. BUILD_PLUGIN: tuic
  192. run: |
  193. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  194. echo "ndk.dir=${ANDROID_HOME}/ndk/25.0.8775105" >> local.properties
  195. export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
  196. cat > service_account_credentials.json << EOF
  197. ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}"
  198. EOF
  199. ./run init action library
  200. ./gradlew :plugin:tuic:publishPlayReleaseBundle