release.yml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. name: 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. libcore:
  29. name: Native Build (LibCore)
  30. runs-on: ubuntu-latest
  31. needs: check
  32. steps:
  33. - name: Checkout
  34. uses: actions/checkout@v2
  35. - name: Fetch Status
  36. run: git submodule status library/core > libcore_status
  37. - name: LibCore Cache
  38. id: cache
  39. uses: actions/cache@v2
  40. with:
  41. path: |
  42. app/libs/libcore.aar
  43. key: ${{ hashFiles('.github/workflows/*', 'bin/lib/core/*', 'libcore_status') }}
  44. - name: Install Golang
  45. uses: actions/setup-go@v2
  46. if: steps.cache.outputs.cache-hit != 'true'
  47. with:
  48. go-version: 1.17.1
  49. - name: Gradle cache
  50. uses: actions/cache@v2
  51. if: steps.cache.outputs.cache-hit != 'true'
  52. with:
  53. path: ~/.gradle
  54. key: native-${{ hashFiles('**/*.gradle.kts') }}
  55. - name: Native Build
  56. if: steps.cache.outputs.cache-hit != 'true'
  57. run: |
  58. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  59. echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
  60. ./run lib core
  61. shadowsocks:
  62. name: Native Build (shadowsocks-rust)
  63. runs-on: ubuntu-latest
  64. needs: check
  65. steps:
  66. - name: Checkout
  67. uses: actions/checkout@v2
  68. - name: Fetch Status
  69. run: git submodule status 'library/shadowsocks/*' > shadowsocks_status
  70. - name: Shadowsocks Cache
  71. id: cache
  72. uses: actions/cache@v2
  73. with:
  74. path: |
  75. app/libs/shadowsocks.aar
  76. key: ${{ hashFiles('library/shadowsocks/build.gradle.kts', 'shadowsocks_status') }}
  77. - name: Install Rust
  78. if: steps.cache.outputs.cache-hit != 'true'
  79. run: ./run init action shadowsocks
  80. - name: Gradle cache
  81. uses: actions/cache@v2
  82. if: steps.cache.outputs.cache-hit != 'true'
  83. with:
  84. path: ~/.gradle
  85. key: native-${{ hashFiles('**/*.gradle.kts') }}
  86. - name: Native Build
  87. if: steps.cache.outputs.cache-hit != 'true'
  88. env:
  89. BUILD_PLUGIN: none
  90. run: |
  91. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  92. echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
  93. ./run init action library
  94. ./run lib shadowsocks
  95. shadowsocks_libev:
  96. name: Native Build (shadowsocks-libev)
  97. runs-on: ubuntu-latest
  98. needs: check
  99. steps:
  100. - name: Checkout
  101. uses: actions/checkout@v2
  102. - name: Fetch Status
  103. run: git submodule status 'library/shadowsocks-libev/*' > shadowsocks_status
  104. - name: Shadowsocks Cache
  105. id: cache
  106. uses: actions/cache@v2
  107. with:
  108. path: |
  109. app/libs/shadowsocks-libev.aar
  110. key: ${{ hashFiles('library/shadowsocks-libev/build.gradle.kts', 'shadowsocks_status') }}
  111. - name: Gradle cache
  112. uses: actions/cache@v2
  113. if: steps.cache.outputs.cache-hit != 'true'
  114. with:
  115. path: ~/.gradle
  116. key: native-${{ hashFiles('**/*.gradle.kts') }}
  117. - name: Native Build
  118. if: steps.cache.outputs.cache-hit != 'true'
  119. env:
  120. BUILD_PLUGIN: none
  121. run: |
  122. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  123. echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
  124. ./run init action library
  125. ./run lib shadowsocks_libev
  126. build:
  127. name: Gradle Build
  128. runs-on: ubuntu-latest
  129. needs:
  130. - libcore
  131. - shadowsocks
  132. - shadowsocks_libev
  133. steps:
  134. - name: Checkout
  135. uses: actions/checkout@v2
  136. - name: Fetch Status
  137. run: |
  138. git submodule status 'library/shadowsocks/*' > shadowsocks_status
  139. git submodule status 'library/shadowsocks-libev/*' > shadowsocks_libev_status
  140. git submodule status library/core > libcore_status
  141. - name: LibCore Cache
  142. uses: actions/cache@v2
  143. with:
  144. path: |
  145. app/libs/libcore.aar
  146. key: ${{ hashFiles('.github/workflows/*', 'bin/lib/core/*', 'libcore_status') }}
  147. - name: Shadowsocks Cache
  148. uses: actions/cache@v2
  149. with:
  150. path: |
  151. app/libs/shadowsocks.aar
  152. key: ${{ hashFiles('library/shadowsocks/build.gradle.kts', 'shadowsocks_status') }}
  153. - name: Shadowsocks (libev) Cache
  154. uses: actions/cache@v2
  155. with:
  156. path: |
  157. app/libs/shadowsocks-libev.aar
  158. key: ${{ hashFiles('library/shadowsocks-libev/build.gradle.kts', 'shadowsocks_libev_status') }}
  159. - name: Gradle cache
  160. uses: actions/cache@v2
  161. with:
  162. path: ~/.gradle
  163. key: gradle-${{ hashFiles('**/*.gradle.kts') }}
  164. - name: Release Build
  165. env:
  166. BUILD_PLUGIN: none
  167. run: |
  168. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  169. echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
  170. export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
  171. ./run init action library
  172. ./gradlew app:assembleOssRelease
  173. APK=$(find app/build/outputs/apk -name '*arm64-v8a*.apk')
  174. APK=$(dirname $APK)
  175. echo "APK=$APK" >> $GITHUB_ENV
  176. - uses: actions/upload-artifact@v2
  177. with:
  178. name: APKs
  179. path: ${{ env.APK }}
  180. - uses: actions/upload-artifact@v2
  181. with:
  182. name: "SHA256-ARM ${{ env.SHA256_ARM }}"
  183. path: ${{ env.SUM_ARM }}
  184. - uses: actions/upload-artifact@v2
  185. with:
  186. name: "SHA256-ARM64 ${{ env.SHA256_ARM64 }}"
  187. path: ${{ env.SUM_ARM64 }}
  188. - uses: actions/upload-artifact@v2
  189. with:
  190. name: "SHA256-X64 ${{ env.SHA256_X64 }}"
  191. path: ${{ env.SUM_X64 }}
  192. - uses: actions/upload-artifact@v2
  193. with:
  194. name: "SHA256-X86 ${{ env.SHA256_X86 }}"
  195. path: ${{ env.SUM_X86 }}
  196. publish:
  197. name: Publish Release
  198. if: github.event.inputs.publish != 'y'
  199. runs-on: ubuntu-latest
  200. needs: build
  201. steps:
  202. - name: Checkout
  203. uses: actions/checkout@v2
  204. - name: Donwload Artifacts
  205. uses: actions/download-artifact@v2
  206. with:
  207. name: APKs
  208. path: artifacts
  209. - name: Release
  210. run: |
  211. wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
  212. tar -xvf ghr.tar.gz
  213. mv ghr*linux_amd64/ghr .
  214. mkdir apks
  215. find artifacts -name "*.apk" -exec cp {} apks \;
  216. find artifacts -name "*.sha256sum.txt" -exec cp {} apks \;
  217. ./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks
  218. upload:
  219. name: Upload Release
  220. if: github.event.inputs.upload != 'y'
  221. runs-on: ubuntu-latest
  222. needs: build
  223. steps:
  224. - name: Donwload Artifacts
  225. uses: actions/download-artifact@v2
  226. with:
  227. name: APKs
  228. path: artifacts
  229. - name: Release
  230. run: |
  231. mkdir apks
  232. find artifacts -name "*.apk" -exec cp {} apks \;
  233. function upload() {
  234. for apk in $@; do
  235. echo ">> Uploading $apk"
  236. curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \
  237. -X POST \
  238. -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \
  239. -F document="@$apk" \
  240. --silent --show-error --fail >/dev/null &
  241. done
  242. for job in $(jobs -p); do
  243. wait $job || exit 1
  244. done
  245. }
  246. upload apks/*
  247. play:
  248. name: Publish to Play Store
  249. if: github.event.inputs.play != 'y'
  250. runs-on: ubuntu-latest
  251. needs:
  252. - libcore
  253. - shadowsocks
  254. - shadowsocks_libev
  255. steps:
  256. - name: Checkout
  257. uses: actions/checkout@v2
  258. - name: Fetch Status
  259. run: |
  260. git submodule status 'library/shadowsocks/*' > shadowsocks_status
  261. git submodule status 'library/shadowsocks-libev/*' > shadowsocks_libev_status
  262. git submodule status library/core > libcore_status
  263. - name: LibCore Cache
  264. uses: actions/cache@v2
  265. with:
  266. path: |
  267. app/libs/libcore.aar
  268. key: ${{ hashFiles('.github/workflows/*', 'bin/lib/core/*', 'libcore_status') }}
  269. - name: Shadowsocks Cache
  270. uses: actions/cache@v2
  271. with:
  272. path: |
  273. app/libs/shadowsocks.aar
  274. key: ${{ hashFiles('library/shadowsocks/build.gradle.kts', 'shadowsocks_status') }}
  275. - name: Shadowsocks (libev) Cache
  276. uses: actions/cache@v2
  277. with:
  278. path: |
  279. app/libs/shadowsocks-libev.aar
  280. key: ${{ hashFiles('library/shadowsocks-libev/build.gradle.kts', 'shadowsocks_libev_status') }}
  281. - name: Gradle cache
  282. uses: actions/cache@v2
  283. with:
  284. path: ~/.gradle
  285. key: gradle-${{ hashFiles('**/*.gradle.kts') }}
  286. - name: Checkout Library
  287. run: |
  288. git submodule update --init 'app/*'
  289. - name: Release Build
  290. env:
  291. BUILD_PLUGIN: none
  292. run: |
  293. echo "sdk.dir=${ANDROID_HOME}" > local.properties
  294. echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
  295. export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
  296. cat > service_account_credentials.json << EOF
  297. ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}"
  298. EOF
  299. ./run init action library
  300. ./gradlew app:publishPlayReleaseBundle