android.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. name: Android CI
  2. on:
  3. push:
  4. branches: [ master ]
  5. jobs:
  6. build:
  7. runs-on: ubuntu-latest
  8. env:
  9. CCACHE_DIR: ${{ github.workspace }}/.ccache
  10. CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
  11. CCACHE_NOHASHDIR: true
  12. CCACHE_MAXSIZE: 1G
  13. steps:
  14. - uses: actions/checkout@v3
  15. with:
  16. submodules: 'recursive'
  17. fetch-depth: 0
  18. - name: Setup JDK 17
  19. uses: actions/setup-java@v3
  20. with:
  21. distribution: 'temurin'
  22. java-version: 17
  23. cache: 'gradle'
  24. - name: Retrieve version
  25. run: |
  26. echo VERSION=$(echo ${{ github.event.head_commit.id }} | head -c 10) >> $GITHUB_ENV
  27. - name: Set up ccache
  28. uses: hendrikmuhs/[email protected]
  29. with:
  30. key: ${{ runner.os }}-${{ github.sha }}
  31. restore-keys: ${{ runner.os }}
  32. - name: Build with Gradle
  33. run: |
  34. echo 'org.gradle.caching=true' >> gradle.properties
  35. echo 'org.gradle.parallel=true' >> gradle.properties
  36. echo 'org.gradle.vfs.watch=true' >> gradle.properties
  37. echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
  38. echo 'android.native.buildOutput=verbose' >> gradle.properties
  39. ./gradlew -PappVerName=${{ env.VERSION }} assembleRelease assembleDebug
  40. - name: Upload built apk
  41. if: success()
  42. uses: actions/upload-artifact@v3
  43. with:
  44. name: snapshot
  45. path: |
  46. app/build/outputs/apk
  47. app/build/outputs/mapping
  48. app/release
  49. - name: Post to channel
  50. if: github.ref == 'refs/heads/master'
  51. env:
  52. CHANNEL_ID: ${{ secrets.TELEGRAM_TO }}
  53. BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
  54. FILE: app/release/BiliRoaming_${{ env.VERSION }}.apk
  55. COMMIT_MESSAGE: |+
  56. New push to github\!
  57. ```
  58. ${{ github.event.head_commit.message }}
  59. ```by `${{ github.event.head_commit.author.name }}`
  60. See commit detail [here](${{ github.event.head_commit.url }})
  61. Snapshot apk is attached \(unsupported by TAICHI\)
  62. run: |
  63. ESCAPED=`python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))'`
  64. curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://release%22,%22parse_mode%22:%22MarkdownV2%22,%22caption%22:${ESCAPED}%7D%5D" -F release="@$FILE"