Recovery Build.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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-latest
  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@v4
  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 lib32ncurses-dev x11proto-core-dev libx11-dev tree lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc bc ccache lib32readline-dev lib32z1-dev liblz4-tool libncurses-dev libsdl1.2-dev build-essential libgtk-3-dev libglu1-mesa-dev freeglut3-dev git libxml2 lzop pngcrush schedtool squashfs-tools imagemagick libbz2-dev lzma ncftp qemu-user-static libstdc++-10-dev libncurses6 python3
  74. - name: Install OpenJDK
  75. uses: actions/setup-java@v4
  76. with:
  77. distribution: 'zulu'
  78. java-version: '11'
  79. - name: Setup SSH Keys
  80. if: ${{ startsWith(github.event.inputs.MANIFEST_URL, 'git@github.com') ||
  81. startsWith(github.event.inputs.DEVICE_TREE_URL, 'git@github.com') ||
  82. startsWith(github.event.inputs.COMMON_TREE_URL, 'git@github.com') }}
  83. uses: webfactory/ssh-agent@v0.9.0
  84. with:
  85. ssh-private-key: |
  86. ${{ secrets.SSH_PRIVATE_KEY }}
  87. - name: Install repo
  88. run: |
  89. mkdir ~/bin
  90. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  91. chmod a+x ~/bin/repo
  92. sudo ln -sf ~/bin/repo /usr/bin/repo
  93. - name: Initialize repo
  94. run: |
  95. mkdir workspace
  96. cd workspace
  97. echo "workspace-folder=$(pwd)" >> $GITHUB_OUTPUT
  98. git config --global user.name "Nico170420"
  99. git config --global user.email "b170420nc@gmail.com"
  100. repo init --depth=1 -u ${{ github.event.inputs.MANIFEST_URL }} -b ${{ github.event.inputs.MANIFEST_BRANCH }}
  101. id: pwd
  102. - name: Repo Sync
  103. run: |
  104. repo sync -j$(nproc --all) --force-sync
  105. working-directory: workspace
  106. - name: Clone device tree
  107. run: |
  108. git clone ${{ github.event.inputs.DEVICE_TREE_URL }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }}
  109. working-directory: ${{ steps.pwd.outputs.workspace-folder }}
  110. - name: Clone common tree
  111. if: |
  112. github.event.inputs.COMMON_TREE_URL != null
  113. && github.event.inputs.COMMON_PATH != null
  114. run: |
  115. git clone ${{ github.event.inputs.COMMON_TREE_URL }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.COMMON_PATH }}
  116. working-directory: ${{ steps.pwd.outputs.workspace-folder }}
  117. - name: Check Build Tree
  118. uses: haya14busa/action-cond@v1
  119. id: buildtree
  120. with:
  121. cond: ${{ github.event.inputs.MANIFEST_BRANCH == 'twrp-11' || github.event.inputs.MANIFEST_BRANCH == 'twrp-12.1' }}
  122. if_true: twrp
  123. if_false: omni
  124. - name: Sync Device Dependencies
  125. run: |
  126. bash ${GITHUB_WORKSPACE}/scripts/convert.sh ${{ github.event.inputs.DEVICE_PATH }}/${{ steps.buildtree.outputs.value }}.dependencies
  127. repo sync -j$(nproc --all)
  128. working-directory: ${{ steps.pwd.outputs.workspace-folder }}
  129. continue-on-error: true
  130. - name: Set Swap Space
  131. uses: pierotofy/set-swap-space@master
  132. with:
  133. swap-size-gb: 12
  134. - name: Building recovery
  135. run: |
  136. source build/envsetup.sh
  137. export ALLOW_MISSING_DEPENDENCIES=true
  138. lunch ${{ github.event.inputs.MAKEFILE_NAME }}-eng && make clean && make ${{ github.event.inputs.BUILD_TARGET }}image -j$(nproc --all)
  139. working-directory: ${{ steps.pwd.outputs.workspace-folder }}
  140. - name: Upload to Release
  141. uses: softprops/action-gh-release@v2
  142. with:
  143. files: |
  144. workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ github.event.inputs.BUILD_TARGET }}.img
  145. workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/*.zip
  146. workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/*vendor*.img
  147. name: ${{ github.event.inputs.DEVICE_NAME }}-${{ github.run_id }}
  148. tag_name: ${{ github.run_id }}
  149. body: |
  150. Manifest: ${{ github.event.inputs.MANIFEST_BRANCH }}
  151. Device: ${{ github.event.inputs.DEVICE_NAME }}
  152. Target: ${{ github.event.inputs.BUILD_TARGET }}.img
  153. env:
  154. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}