android.yml 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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: Write key
  33. if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/master' ) || github.ref_type == 'tag' }}
  34. run: |
  35. if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then
  36. echo 'Writing sign key'
  37. echo releaseStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties
  38. echo releaseKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties
  39. echo releaseKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
  40. echo releaseStoreFile='key.jks' >> gradle.properties
  41. echo '${{ secrets.SIGNING_KEY }}' | base64 --decode > key.jks
  42. fi
  43. - name: Build with Gradle
  44. run: |
  45. echo 'org.gradle.caching=true' >> gradle.properties
  46. echo 'org.gradle.parallel=true' >> gradle.properties
  47. echo 'org.gradle.vfs.watch=true' >> gradle.properties
  48. echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
  49. echo 'android.native.buildOutput=verbose' >> gradle.properties
  50. ./gradlew -PappVerName=${{ env.VERSION }} assembleRelease assembleDebug
  51. - name: Upload built apk
  52. if: success()
  53. uses: actions/upload-artifact@v4
  54. with:
  55. name: snapshot
  56. path: |
  57. app/build/outputs/apk
  58. app/build/outputs/mapping
  59. app/release
  60. - name: Post to channel
  61. if: github.ref == 'refs/heads/master'
  62. env:
  63. CHANNEL_ID: ${{ secrets.TELEGRAM_TO }}
  64. BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
  65. FILE: app/release/BiliRoaming_${{ env.VERSION }}.apk
  66. COMMIT_MESSAGE: |+
  67. New push to github\!
  68. ```
  69. ${{ github.event.head_commit.message }}
  70. ```by `${{ github.event.head_commit.author.name }}`
  71. See commit detail [here](${{ github.event.head_commit.url }})
  72. Snapshot apk is attached \(unsupported by TAICHI\)
  73. run: |
  74. ESCAPED=`python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))'`
  75. 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"