release_pingtunnel.yml 6.1 KB

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