Recovery Build.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. name: Recovery Build
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. MANIFEST_URL:
  6. description: 'MANIFEST_URL (if want to use SSH keys, use git@github.com:XXXXX)'
  7. required: true
  8. default: 'https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp'
  9. MANIFEST_BRANCH:
  10. description: 'MANIFEST_BRANCH'
  11. required: true
  12. default: 'twrp-12.1'
  13. DEVICE_TREE_URL:
  14. description: 'DEVICE_TREE_URL'
  15. required: true
  16. default: 'https://github.com/TeamWin/android_device_asus_I003D'
  17. DEVICE_TREE_BRANCH:
  18. description: 'DEVICE_TREE_BRANCH'
  19. required: true
  20. default: 'android-12.1'
  21. DEVICE_PATH:
  22. description: 'DEVICE_PATH'
  23. required: true
  24. default: 'device/asus/I003D'
  25. COMMON_TREE_URL:
  26. description: 'COMMON_TREE_URL (if no common tree, leave blank)'
  27. required: false
  28. COMMON_PATH:
  29. description: 'COMMON_PATH (if no common tree, leave blank)'
  30. required: false
  31. DEVICE_NAME:
  32. description: 'DEVICE_NAME'
  33. required: true
  34. default: 'I003D'
  35. MAKEFILE_NAME:
  36. description: 'MAKEFILE_NAME'
  37. required: true
  38. default: 'twrp_I003D'
  39. BUILD_TARGET:
  40. description: 'BUILD_TARGET'
  41. required: true
  42. default: 'recovery'
  43. jobs:
  44. build:
  45. if: github.event.repository.owner.id == github.event.sender.id
  46. runs-on: ubuntu-20.04
  47. permissions:
  48. contents: write
  49. steps:
  50. - name: Display Run Parameters
  51. run: |
  52. echo "::group::User Environment Variables"
  53. echo "Manifest URL: ${{ github.event.inputs.MANIFEST_URL }}"
  54. echo "Manifest Branch: ${{ github.event.inputs.MANIFEST_BRANCH }}"
  55. echo "Device Tree URL: ${{ github.event.inputs.DEVICE_TREE_URL }}"
  56. echo "Device Tree Branch: ${{ github.event.inputs.DEVICE_TREE_BRANCH }}"
  57. echo "Device Path: ${{ github.event.inputs.DEVICE_PATH }}"
  58. echo "Device Name: ${{ github.event.inputs.DEVICE_NAME }}"
  59. echo "Makefile Name: ${{ github.event.inputs.MAKEFILE_NAME }}"
  60. echo "Build Target: ${{ github.event.inputs.BUILD_TARGET }}.img"
  61. echo "::endgroup::"
  62. # You might want to Checkout your repo first, but not mandatory
  63. - name: Check Out
  64. uses: actions/checkout@v3
  65. # Cleanup The Actions Workspace Using Custom Composite Run Actions
  66. - name: Cleanup
  67. uses: rokibhasansagar/slimhub_actions@main
  68. # That's it! Now use your normal steps
  69. - name: Prepare the environment
  70. run: |
  71. sudo apt update
  72. sudo apt -y upgrade
  73. sudo apt -y install gperf gcc-multilib gcc-10-multilib g++-multilib g++-10-multilib libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev tree lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc bc ccache lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 lzop pngcrush schedtool squashfs-tools imagemagick libbz2-dev lzma ncftp qemu-user-static libstdc++-10-dev libncurses5 python
  74. - name: Install OpenJDK
  75. uses: actions/setup-java@v3
  76. with:
  77. distribution: 'zulu'
  78. java-version: '8'
  79. - name: Setup SSH Keys
  80. if: ${{ startsWith(github.event.inputs.MANIFEST_URL, 'git@github.com') }}
  81. uses: webfactory/ssh-agent@v0.5.4
  82. with:
  83. ssh-private-key: |
  84. ${{ secrets.SSH_PRIVATE_KEY }}
  85. - name: Install repo
  86. run: |
  87. mkdir ~/bin
  88. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  89. chmod a+x ~/bin/repo
  90. sudo ln -sf ~/bin/repo /usr/bin/repo
  91. - name: Initialize repo
  92. run: |
  93. mkdir workspace
  94. cd workspace
  95. echo "workspace-folder=$(pwd)" >> $GITHUB_OUTPUT
  96. git config --global user.name "Nico170420"
  97. git config --global user.email "b170420nc@gmail.com"
  98. repo init --depth=1 -u ${{ github.event.inputs.MANIFEST_URL }} -b ${{ github.event.inputs.MANIFEST_BRANCH }}
  99. id: pwd
  100. - name: Repo Sync
  101. run: |
  102. repo sync -j$(nproc --all) --force-sync
  103. working-directory: workspace
  104. - name: Clone device tree
  105. run: |
  106. git clone ${{ github.event.inputs.DEVICE_TREE_URL }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }}
  107. working-directory: ${{ steps.pwd.outputs.workspace-folder }}
  108. - name: Clone common tree
  109. if: |
  110. github.event.inputs.COMMON_TREE_URL != null
  111. && github.event.inputs.COMMON_PATH != null
  112. run: |
  113. git clone ${{ github.event.inputs.COMMON_TREE_URL }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.COMMON_PATH }}
  114. working-directory: ${{ steps.pwd.outputs.workspace-folder }}
  115. - name: Check Build Tree
  116. uses: haya14busa/action-cond@v1
  117. id: buildtree
  118. with:
  119. cond: ${{ github.event.inputs.MANIFEST_BRANCH == 'twrp-11' || github.event.inputs.MANIFEST_BRANCH == 'twrp-12.1' }}
  120. if_true: twrp
  121. if_false: omni
  122. - name: Sync Device Dependencies
  123. run: |
  124. bash ${GITHUB_WORKSPACE}/scripts/convert.sh ${{ github.event.inputs.DEVICE_PATH }}/${{ steps.buildtree.outputs.value }}.dependencies
  125. repo sync -j$(nproc --all)
  126. working-directory: ${{ steps.pwd.outputs.workspace-folder }}
  127. continue-on-error: true
  128. - name: Set Swap Space
  129. uses: pierotofy/set-swap-space@master
  130. with:
  131. swap-size-gb: 12
  132. - name: Building recovery
  133. run: |
  134. source build/envsetup.sh
  135. export ALLOW_MISSING_DEPENDENCIES=true
  136. lunch ${{ github.event.inputs.MAKEFILE_NAME }}-eng && make clean && make ${{ github.event.inputs.BUILD_TARGET }}image -j$(nproc --all)
  137. working-directory: ${{ steps.pwd.outputs.workspace-folder }}
  138. - name: Upload to Release
  139. uses: softprops/action-gh-release@v1
  140. with:
  141. files: workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ github.event.inputs.BUILD_TARGET }}.img
  142. name: ${{ github.event.inputs.DEVICE_NAME }}-${{ github.run_id }}
  143. tag_name: ${{ github.run_id }}
  144. body: |
  145. Manifest: ${{ github.event.inputs.MANIFEST_BRANCH }}
  146. Device: ${{ github.event.inputs.DEVICE_NAME }}
  147. Target: ${{ github.event.inputs.BUILD_TARGET }}.img
  148. env:
  149. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}