Skip to content

Commit 93465d7

Browse files
committed
Feature: Add system & twrp builder.
* Add DogDayBuilder. * Move kernel builder to seperate directory. * Add OrangeFox builder. * Add a script to clear all tags and releases.
1 parent f8d6f9d commit 93465d7

34 files changed

+1692
-974
lines changed

.Scripts/CleanUp.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Delete all tags & releases
2+
gh release list | awk -F '\\t' '{print $3}' | while read -r line; do gh release delete -y "$line" --cleanup-tag; done

.github/workflows/build.yml renamed to .github/workflows/kernel.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build kernels
33
on:
44
push:
55
paths:
6-
- ".github/workflows/build.yml"
6+
- ".github/workflows/kernel.yml"
77
workflow_dispatch:
88
schedule:
99
- cron: "14 13 * * 5"
@@ -25,7 +25,7 @@ jobs:
2525
id: generate-matrix
2626
run: |
2727
echo "CONFIGS<<EOF" >> $GITHUB_OUTPUT
28-
jq -s '[.[][]]' configs/*.config.json >> $GITHUB_OUTPUT
28+
jq -s '[.[][]]' Kernel/configs/*.config.json >> $GITHUB_OUTPUT
2929
echo "EOF" >> $GITHUB_OUTPUT
3030
3131
# Set compile time.
@@ -72,7 +72,7 @@ jobs:
7272

7373
# Set output & ccache directory
7474
OUT_DIR: "${{ github.workspace }}/out"
75-
CCACHE_DIR: "${{ github.workspace }}/out"
75+
CCACHE_DIR: "${{ github.workspace }}/ccache"
7676
steps:
7777
# Set swap space
7878
- name: 📐 Set swap to 10G

.github/workflows/twrp.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Build TWRPs
2+
3+
on:
4+
push:
5+
paths:
6+
- ".github/workflows/twrp.yml"
7+
workflow_dispatch:
8+
schedule:
9+
- cron: "14 13 * * 5"
10+
11+
jobs:
12+
Read-configuration:
13+
name: 🏧 Parse *.config.json
14+
runs-on: ubuntu-latest
15+
outputs:
16+
CONFIGS: ${{ steps.generate-matrix.outputs.CONFIGS }}
17+
BUILD_DATE: ${{ steps.generate-builddate.outputs.BUILDDATE }}
18+
steps:
19+
# This action checks-out your CONFIGSitory under $GITHUB_WORKSPACE, so your workflow can access it.
20+
- name: ♈ Checkout
21+
uses: actions/checkout@v4
22+
23+
# Match the configuration files in the CONFIGS directory, read the contents and merge them into an array.
24+
- name: ♉ Generate Matrix
25+
id: generate-matrix
26+
run: |
27+
echo "CONFIGS<<EOF" >> $GITHUB_OUTPUT
28+
jq -s '[.[][]]' TWRP/configs/*.config.json >> $GITHUB_OUTPUT
29+
echo "EOF" >> $GITHUB_OUTPUT
30+
31+
# Set compile time.
32+
- name: ♊ Set builddate
33+
id: generate-builddate
34+
run: echo "BUILDDATE=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
35+
36+
Build-TWRP:
37+
name: 🛄 Build TWRP
38+
runs-on: ubuntu-latest
39+
needs:
40+
- Read-configuration
41+
strategy:
42+
max-parallel: 4
43+
fail-fast: false
44+
matrix:
45+
CONFIG: ${{ fromJSON(needs.Read-configuration.outputs.CONFIGS) }}
46+
env:
47+
# Basic configuration
48+
WORKSPACE: ${{ github.workspace }}
49+
BUILD_DATE: ${{ needs.Read-configuration.outputs.BUILD_DATE }}
50+
51+
# OrangeFox sync scripts configuration
52+
OF_LOCATION: ${{ github.workspace }}/OrangeFox
53+
OF_SYNC_REPO: ${{ matrix.CONFIG.OrangeFox.Repo }}
54+
OF_SYNC_BRANCH: ${{ matrix.CONFIG.OrangeFox.Branch }}
55+
56+
# DeviceTree configuration
57+
DEVICE_REPO: ${{ matrix.CONFIG.Device.Repo }}
58+
DEVICE_BRANCH: ${{ matrix.CONFIG.Device.Branch }}
59+
DEVICE_LOCATION: ${{ matrix.CONFIG.Device.Location }}
60+
DEVICE_NAME: ${{ matrix.CONFIG.Device.DeviceName }}
61+
DEVICE_MAKEFILE: ${{ matrix.CONFIG.Device.Makefile }}
62+
DEVICE_BOOT_PARTITION: ${{ matrix.CONFIG.Device.BootPartition }}
63+
64+
# Set output & ccache directory
65+
OUT_DIR: "${{ github.workspace }}/out"
66+
CCACHE_DIR: "${{ github.workspace }}/ccache"
67+
steps:
68+
# Clean up the workspace and make room for compilation
69+
- name: ♋ Cleanup
70+
uses: rokibhasansagar/slimhub_actions@main
71+
72+
- name: ♌ Prepare the build environment
73+
run: |
74+
cd ~
75+
sudo apt install git aria2 -y
76+
git clone https://gitlab.com/OrangeFox/misc/scripts
77+
cd scripts
78+
sudo bash setup/android_build_env.sh
79+
sed -i 's/cd -/cd ../g' setup/install_android_sdk.sh
80+
sudo bash setup/install_android_sdk.sh
81+
82+
- name: ♍ Sync OrangeFox sources and minimal manifest
83+
run: |
84+
git clone ${{ env.OF_SYNC_REPO }} sync
85+
cd sync
86+
./orangefox_sync.sh --branch ${{ env.OF_SYNC_BRANCH }} --path ${{ env.OF_LOCATION }}
87+
88+
- name: ♎ Place device trees and kernel
89+
working-directory: ${{ env.OF_LOCATION }}
90+
run: |
91+
git clone --recursive --depth=1 -j $(nproc) --branch ${{ env.DEVICE_BRANCH }} ${{ env.DEVICE_REPO }} ${{ env.DEVICE_LOCATION }}
92+
93+
- name: ♏ Set Swap Space
94+
uses: pierotofy/set-swap-space@master
95+
with:
96+
swap-size-gb: 12
97+
98+
- name: ♐ Build it
99+
working-directory: ${{ env.OF_LOCATION }}
100+
continue-on-error: true
101+
run: |
102+
set +e
103+
source build/envsetup.sh
104+
export ALLOW_MISSING_DEPENDENCIES=true
105+
export FOX_BUILD_DEVICE=thyme
106+
export LC_ALL="C"
107+
set -e
108+
lunch ${{ env.DEVICE_MAKEFILE }}-eng && mka adbd ${{ env.DEVICE_BOOT_PARTITION }}image -j$(nproc --all)
109+
110+
- name: ♑Take the OrangeFox build
111+
uses: actions/upload-artifact@v3
112+
with:
113+
name: OrangeFox
114+
if-no-files-found: warn
115+
path: |
116+
${{ env.OUT_DIR }}/target/product/${{ env.DEVICE_NAME }}/*${{ env.DEVICE_NAME }}.img
117+
${{ env.OUT_DIR }}/target/product/${{ env.DEVICE_NAME }}/*${{ env.DEVICE_NAME }}.zip
118+
119+
- name: ♒ Create GitHub Release => (${{ env.BUILD_DATE }})
120+
continue-on-error: true
121+
uses: softprops/action-gh-release@v1
122+
with:
123+
tag_name: v${{ env.BUILD_DATE }}.${{ github.run_number }}
124+
files: |
125+
${{ env.OUT_DIR }}/target/product/${{ env.DEVICE_NAME }}/*${{ env.DEVICE_NAME }}.img
126+
${{ env.OUT_DIR }}/target/product/${{ env.DEVICE_NAME }}/*${{ env.DEVICE_NAME }}.zip
127+
generate_release_notes: true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Kernel/README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Build Your Own Kernel
2+
3+
English | [中文文档](./README.zh_CN.md)
4+
5+
In this part, we will use `Github Action` to perform kernel cloud compilation. The directory structure of this project is as follows:
6+
7+
```sh
8+
.
9+
├── configs
10+
│   ├── markw.config.json
11+
│   ├── thyme.config.json
12+
│   └── wayne.config.json
13+
└── LXC
14+
   ├── LXC_defconfig
15+
   └── Patches
16+
      ├── cgroup.patch
17+
      └── xt_qtaguid.patch
18+
```
19+
20+
The contents and functions of each part are as follows:
21+
22+
- **configs**: used to store the detailed configuration of all kernels to be compiled (kernel source code address, compilation tool chain, compilation parameters and additional compilation options)
23+
- **LXC**: stores some configuration files and patches required for kernel support `Docker`
24+
- **LXC_defconfig**: Options that need to be enabled for kernel support `Docker`
25+
- **Patches**: Some patches that need to be applied
26+
27+
## Development progress
28+
29+
- [x] `AnyKernel3` original and customized versions supported
30+
- [x] `KernelSU` compilation support
31+
- [x] `Docker` compilation support
32+
- [x] Use repository owner information to compile
33+
- [ ] Use `MagiskBoot` to generate `boot.img`
34+
- [ ] Compile kernel script locally
35+
- [ ] Web page configuration Json compilation configuration file (to be released soon)
36+
- [ ] Cloud compiled kernel web page
37+
38+
## Github Action
39+
40+
### Introduction to the compilation process
41+
42+
The `Github Action` file for compiling the kernel is [kernel.yml](../.github/workflows/kernel.yml). This Action contains the following two jobs:
43+
44+
- `Read-configuration`: used to read the configuration files in the `configs` folder
45+
- `Build-Kernel`: Compile the text kernel according to the read configuration file, and perform functions such as uploading
46+
47+
### Compilation process timeline
48+
49+
```mermaid
50+
%%{init: { 'logLevel': 'debug', 'theme': 'neutral' } }%%
51+
timeline
52+
How to build a Kernel
53+
section Read configuration
54+
Checkout repository
55+
Generate configuration matrix
56+
Set builddate
57+
section Kernel Build
58+
Prepare : 📐 Set swap to 10G : 😄 Checkout repository
59+
: ⭐ Install prerequisites for Ubuntu : 🚄 Setup ccache : 🚅 Restore cache
60+
: 🌟 Clone kernel source : 💫 Get toolchains
61+
Basic configuration : 😎 Set build args : 😋 Setup KernelSU : 😋 Setup LXC Docker
62+
: 👍 Build kernel
63+
section Post build
64+
Upload Artifact : 💛 Upload Image : 💙 Upload Image.gz : 💙 Upload Image.gz-dtb
65+
: 💜 Upload dtb : ❤️ Upload dtbo.img : ☢️ Upload output directory
66+
Pack Anykernel3 : ⏰ Get Anykernel3 : ⏰ Pack your kernel : 💾 Upload AnyKernel3 package
67+
Release
68+
```
69+
70+
## Configuration file parsing
71+
72+
Please see [Compile Configuration](./configs/) for specific configuration methods.
73+
74+
## Instructions
75+
76+
The basic usage of this project is as follows:
77+
78+
1. `fork` this project on GitHub
79+
80+
2. Modify the `config/*.config.json` file through the Github web page or pull it locally, and submit the changes
81+
82+
3. View the `Action` page of the Github page and find `Build kernels` and `Run workflow`
83+
84+
4. After the compilation is completed, you can enter the corresponding page to download the compiled product.
85+
86+
5. Use your favorite packaging software for kernel packaging ([AnyKernel3](https://github.com/osm0sis/AnyKernel3), [Android-Image-Kitchen](https://github.com/osm0sis/Android-Image-Kitchen), [MagiskBoot](https://github.com/topjohnwu/Magisk/releases), etc. **Currently this project only integrates AnyKernel3**)
87+
88+
![Artifacts](https://github.com/DogDayAndroid/Android-Builder/blob/main/.assets/artifacts.png?raw=true)
89+
90+
## Local build
91+
92+
### 1. Run `Action` locally
93+
94+
If you don't want to repeatedly execute `Action` on `Github`, you can use [nektos/act](https://github.com/nektos/act) to test this build process and output it in the local environment.
95+
96+
After installing [nektos/act](https://github.com/nektos/act) and execute the following instructions:
97+
98+
```sh
99+
# Collect build files into the /tmp/artifacts folder:
100+
act --artifact-server-path /tmp/artifacts
101+
```
102+
103+
If you need to place it in a local location you like, please change `/tmp/artifacts` to your preferred directory.
104+
105+
If an error is reported during the process, please add the parameter `-v` and re-execute to obtain the error report and submit an `issue`. The specific command is as follows:
106+
107+
```sh
108+
# Collect build files into the /tmp/artifacts folder:
109+
act --artifact-server-path /tmp/artifacts -v
110+
```
111+
112+
## FAQ
113+
114+
### 1. GitHub release failed with status: `403`
115+
116+
When you use `softprops/action-gh-release@v1` to publish `Release`, you may encounter the following error:
117+
118+
```plaintext
119+
👩‍🏭 Creating new GitHub release for tag v20230619.7...
120+
⚠️ GitHub release failed with status: 403
121+
undefined
122+
retrying... (2 retries remaining)
123+
👩‍🏭 Creating new GitHub release for tag v20230619.7...
124+
⚠️ GitHub release failed with status: 403
125+
undefined
126+
retrying... (1 retries remaining)
127+
👩‍🏭 Creating new GitHub release for tag v20230619.7...
128+
⚠️ GitHub release failed with status: 403
129+
undefined
130+
retrying... (0 retries remaining)
131+
❌ Too many retries. Aborting...
132+
Error: Too many retries.
133+
```
134+
135+
This is caused by your `Workflow` not having **read and write permission**:
136+
137+
![workflow permissions](https://github.com/DogDayAndroid/Android-Builder/blob/main/.assets/FAQ/workflow%20permissions.png?raw=true)
138+
139+
Open the corresponding read and write permissions as shown above, and then re-run `Action` to publish your own `Release`
140+
141+
# Acknowledgments
142+
143+
- [weishu](https://github.com/tiann) : Developer of KernelSU
144+
- [AKR Android Developer Community](https://www.akr-developers.com/) : Provides build tutorials
145+
- [DogDayAndroid/KSU_Thyme_BuildBot](https://github.com/DogDayAndroid/KSU_Thyme_BuildBot) : Predecessor of this project
146+
- [xiaoleGun/KernelSU_Action](https://github.com/xiaoleGun/KernelSU_Action) : Drawing on some Github Actions
147+
- [UtsavBalar1231/Drone-scripts](https://github.com/UtsavBalar1231/Drone-scripts) : Drawing on some Github Actions

0 commit comments

Comments
 (0)