build.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. name: CI
  2. on:
  3. push:
  4. branches: [ master ]
  5. jobs:
  6. build:
  7. strategy:
  8. matrix:
  9. os: [ubuntu-latest]
  10. runs-on: ${{matrix.os}}
  11. steps:
  12. - uses: actions/checkout@v2
  13. - name: Set Release Version
  14. id: get_version
  15. shell: bash
  16. run: |
  17. echo "::set-output name=hash::$(git rev-parse --short HEAD)"
  18. echo "::set-output name=url::$(git config --get remote.origin.url)"
  19. echo "::set-output name=date::$(date +%Y%m%d)"
  20. - name: Setup Java JDK
  21. uses: actions/setup-java@v2
  22. with:
  23. distribution: 'adopt'
  24. java-version: "16"
  25. - name: Flutter action
  26. uses: subosito/flutter-action@v1.5.3
  27. with:
  28. channel: "stable"
  29. flutter-version: "3.13.5"
  30. - name: Cache Dependencies
  31. id: cache
  32. uses: actions/cache@v2
  33. with:
  34. path: |
  35. ~/.gradle/caches
  36. ~/.gradle/wrapper
  37. Pods
  38. ~/local/rubies
  39. key: |
  40. ${{runner.OS}}-gradle-caches-${{ hashFiles('pubspec.lock') }}
  41. ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
  42. restore-keys: |
  43. ${{ runner.os }}-pods-
  44. ${{ runner.os }}-gradle-
  45. - name: Install Dependencies
  46. if: steps.cache.outputs.cache-hit != 'true'
  47. run: flutter pub get
  48. - name: Build apk
  49. if: ${{ runner.os == 'Linux' }}
  50. run: flutter build apk --debug --split-per-abi
  51. - name: Update to ali oss
  52. uses: yizhoumo/setup-ossutil@v1
  53. with:
  54. endpoint: oss-cn-qingdao.aliyuncs.com
  55. access-key-id: ${{ secrets.OSS_KEY_ID }}
  56. access-key-secret: ${{ secrets.OSS_KEY_SECRET }}
  57. - name: cp files to aliyun
  58. run: |
  59. ossutil cp -r --include "*.apk" build/app/outputs/flutter-apk oss://yoqi-software/develop/flutter_cocktail/${{ steps.get_version.outputs.date }}-${{ steps.get_version.outputs.hash }}/
  60. - uses: leafney/dingtalk-action@v1
  61. if: always()
  62. env:
  63. DINGTALK_ACCESS_TOKEN: ${{ secrets.DINGTALK_ACCESS_TOKEN }}
  64. with:
  65. msgtype: link
  66. title: 'build success'
  67. text: 'flutter_cocktail has been build success, please download from aliyun oss. [git.yoqi.me]'
  68. msg_url: '${{ steps.get_version.outputs.url }}'