release_mieru.yml 6.2 KB

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