release_naive.yml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. name: NaïveProxy 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. runs-on: ubuntu-latest
  30. name: Native Build (NaïveProxy)
  31. strategy:
  32. fail-fast: false
  33. matrix:
  34. arch: [ armeabi-v7a, arm64-v8a, x86, x86_64 ]
  35. steps:
  36. - name: Checkout
  37. uses: actions/checkout@v2
  38. - name: Fetch Status
  39. run: git submodule status 'plugin/naive/*' > naive_status
  40. - name: Naive Cache
  41. id: cache
  42. uses: actions/cache@v2
  43. with:
  44. path: |
  45. plugin/naive/src/main/jniLibs/${{ matrix.arch }}
  46. key: naive-${{ matrix.arch }}-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  47. - name: Gradle cache
  48. uses: actions/cache@v2
  49. if: steps.cache.outputs.cache-hit != 'true'
  50. with:
  51. path: ~/.gradle
  52. key: native-${{ hashFiles('**/*.gradle.kts') }}
  53. - name: Native Build
  54. if: steps.cache.outputs.cache-hit != 'true'
  55. run: |
  56. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  57. echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
  58. ./run init action naive
  59. ./run plugin naive init
  60. ./run plugin naive ${{ matrix.arch }}
  61. - name: Calculate SHA256
  62. run: |
  63. openssl sha256 plugin/naive/src/main/jniLibs/${{ matrix.arch }}/libnaive.so > sha256sum.txt
  64. echo "SHA256SUM=$(cut -d' ' -f2 sha256sum.txt)" >>$GITHUB_ENV
  65. - uses: actions/upload-artifact@v2
  66. with:
  67. name: "NAIVE-SHA256-${{ matrix.arch }} ${{ env.SHA256SUM }}"
  68. path: sha256sum.txt
  69. build:
  70. name: Gradle Build (NaïveProxy)
  71. runs-on: ubuntu-latest
  72. needs:
  73. - native
  74. - check
  75. steps:
  76. - name: Checkout
  77. uses: actions/checkout@v2
  78. - name: Fetch Status
  79. run: git submodule status 'plugin/naive/*' > naive_status
  80. - name: Naive Cache (armeabi-v7a)
  81. uses: actions/cache@v2
  82. with:
  83. path: |
  84. plugin/naive/src/main/jniLibs/armeabi-v7a
  85. key: naive-armeabi-v7a-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  86. - name: Naive Cache (arm64-v8a)
  87. uses: actions/cache@v2
  88. with:
  89. path: |
  90. plugin/naive/src/main/jniLibs/arm64-v8a
  91. key: naive-arm64-v8a-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  92. - name: Naive Cache (x86)
  93. uses: actions/cache@v2
  94. with:
  95. path: |
  96. plugin/naive/src/main/jniLibs/x86
  97. key: naive-x86-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  98. - name: Naive Cache (x86_64)
  99. uses: actions/cache@v2
  100. with:
  101. path: |
  102. plugin/naive/src/main/jniLibs/x86_64
  103. key: naive-x86_64-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  104. - name: Gradle cache
  105. uses: actions/cache@v2
  106. with:
  107. path: ~/.gradle
  108. key: native-${{ hashFiles('**/*.gradle.kts') }}
  109. - name: Native Build
  110. env:
  111. SKIP_BUILD: on
  112. BUILD_PLUGIN: naive
  113. run: |
  114. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  115. echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
  116. export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
  117. ./run init action library
  118. ./gradlew :plugin:naive:assembleOssRelease
  119. APK=$(find plugin/naive/build/outputs/apk -name '*arm64-v8a*.apk')
  120. APK=$(dirname $APK)
  121. echo "APK=$APK" >> $GITHUB_ENV
  122. - uses: actions/upload-artifact@v2
  123. with:
  124. name: APKs
  125. path: ${{ env.APK }}
  126. - uses: actions/upload-artifact@v2
  127. with:
  128. name: "SHA256-ARM ${{ env.SHA256_ARM }}"
  129. path: ${{ env.SUM_ARM }}
  130. - uses: actions/upload-artifact@v2
  131. with:
  132. name: "SHA256-ARM64 ${{ env.SHA256_ARM64 }}"
  133. path: ${{ env.SUM_ARM64 }}
  134. - uses: actions/upload-artifact@v2
  135. with:
  136. name: "SHA256-X64 ${{ env.SHA256_X64 }}"
  137. path: ${{ env.SUM_X64 }}
  138. - uses: actions/upload-artifact@v2
  139. with:
  140. name: "SHA256-X86 ${{ env.SHA256_X86 }}"
  141. path: ${{ env.SUM_X86 }}
  142. publish:
  143. name: Publish Release
  144. if: github.event.inputs.publish != 'y'
  145. runs-on: ubuntu-latest
  146. needs: build
  147. steps:
  148. - name: Checkout
  149. uses: actions/checkout@v2
  150. - name: Donwload Artifacts
  151. uses: actions/download-artifact@v2
  152. with:
  153. name: APKs
  154. path: artifacts
  155. - name: Release
  156. run: |
  157. wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
  158. tar -xvf ghr.tar.gz
  159. mv ghr*linux_amd64/ghr .
  160. mkdir apks
  161. find artifacts -name "*.apk" -exec cp {} apks \;
  162. find artifacts -name "*.sha256sum.txt" -exec cp {} apks \;
  163. ./ghr -delete -prerelease -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks
  164. upload:
  165. name: Upload Release
  166. if: github.event.inputs.upload != 'y'
  167. runs-on: ubuntu-latest
  168. needs: build
  169. steps:
  170. - name: Donwload Artifacts
  171. uses: actions/download-artifact@v2
  172. with:
  173. name: APKs
  174. path: artifacts
  175. - name: Release
  176. run: |
  177. mkdir apks
  178. find artifacts -name "*.apk" -exec cp {} apks \;
  179. function upload() {
  180. for apk in $@; do
  181. echo ">> Uploading $apk"
  182. curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \
  183. -X POST \
  184. -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \
  185. -F document="@$apk" \
  186. --silent --show-error --fail >/dev/null &
  187. done
  188. for job in $(jobs -p); do
  189. wait $job || exit 1
  190. done
  191. }
  192. upload apks/*
  193. play:
  194. name: Publish to Play Store
  195. if: github.event.inputs.play != 'y'
  196. runs-on: ubuntu-latest
  197. needs:
  198. - native
  199. - check
  200. steps:
  201. - name: Checkout
  202. uses: actions/checkout@v2
  203. - name: Fetch Status
  204. run: git submodule status 'plugin/naive/*' > naive_status
  205. - name: Naive Cache (armeabi-v7a)
  206. uses: actions/cache@v2
  207. with:
  208. path: |
  209. plugin/naive/src/main/jniLibs/armeabi-v7a
  210. key: naive-armeabi-v7a-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  211. - name: Naive Cache (arm64-v8a)
  212. uses: actions/cache@v2
  213. with:
  214. path: |
  215. plugin/naive/src/main/jniLibs/arm64-v8a
  216. key: naive-arm64-v8a-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  217. - name: Naive Cache (x86)
  218. uses: actions/cache@v2
  219. with:
  220. path: |
  221. plugin/naive/src/main/jniLibs/x86
  222. key: naive-x86-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  223. - name: Naive Cache (x86_64)
  224. uses: actions/cache@v2
  225. with:
  226. path: |
  227. plugin/naive/src/main/jniLibs/x86_64
  228. key: naive-x86_64-${{ hashFiles('bin/plugin/naive/*', 'naive_status') }}
  229. - name: Gradle cache
  230. uses: actions/cache@v2
  231. with:
  232. path: ~/.gradle
  233. key: native-${{ hashFiles('**/*.gradle.kts') }}
  234. - name: Native Build
  235. env:
  236. SKIP_BUILD: on
  237. BUILD_PLUGIN: naive
  238. run: |
  239. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  240. echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
  241. export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
  242. cat > service_account_credentials.json << EOF
  243. ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}"
  244. EOF
  245. ./run init action library
  246. ./gradlew :plugin:naive:publishPlayReleaseBundle