release.yml 6.9 KB

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