Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
azwhikaru committed Jun 10, 2021
0 parents commit d6e8e20
Show file tree
Hide file tree
Showing 8 changed files with 1,572 additions and 0 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/actions_recovery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: rec-building

on:
watch:
types: [started]

jobs:
build:
if: github.event.repository.owner.id == github.event.sender.id
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@main

- name: Clean Up
run: |
docker rmi `docker images -q`
sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d
sudo apt -y purge azure-cli ghc* zulu* hhvm llvm* firefox google* dotnet* powershell openjdk* mysql* php*
sudo apt update
sudo apt -y autoremove --purge
sudo apt clean
- name: Update packages
run: |
sudo apt update
sudo apt full-upgrade
- name: Install required packages
run: sudo apt install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev tree lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip jq

- name: Get variables
run: |
echo "::set-output name=twrp_url::$(jq -r '.twrp_url' config.json)"
echo "::set-output name=twrp_branch::$(jq -r '.twrp_branch' config.json)"
echo "::set-output name=git_username::$(jq -r '.git_username' config.json)"
echo "::set-output name=git_email::$(jq -r '.git_email' config.json)"
echo "::set-output name=use_own_dt::$(jq -r '.use_own_dt' config.json)"
echo "::set-output name=dt_url::$(jq -r '.dt_url' config.json)"
echo "::set-output name=dt_remote::$(jq -r '.dt_remote' config.json)"
echo "::set-output name=dt_branch::$(jq -r '.dt_branch' config.json)"
echo "::set-output name=dt_path::$(jq -r '.dt_path' config.json)"
echo "::set-output name=device_code::$(jq -r '.device_code' config.json)"
echo "::set-output name=fix_product::$(jq -r '.fix_product' config.json)"
echo "::set-output name=fix_misscom::$(jq -r '.fix_misscom' config.json)"
echo "::set-output name=fix_busybox::$(jq -r '.fix_busybox' config.json)"
echo "::set-output name=fix_branch::$(jq -r '.fix_branch' config.json)"
echo "::set-output name=date::$(date +%F)"
id: var

- name: Install Repo
run: |
mkdir ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
- name: Initialize Repair Manifest
run: git clone https://github.com/TeamWin/buildtree_manifests.git repair/

- name: Initialize a Repo client
run: |
PATH=~/bin:$PATH
mkdir workspace
cd workspace
echo "::set-output name=pwd::$(pwd)"
git config --global user.name "${{ steps.var.outputs.git_username }}"
git config --global user.email "${{ steps.var.outputs.git_email }}"
repo init --depth=1 -u ${{ steps.var.outputs.twrp_url }} -b ${{ steps.var.outputs.twrp_branch }}
mkdir .repo/local_manifests
id: pwd

- name: Fix the bug of missing common
if: steps.var.outputs.fix_misscom == 'true'
run: cp repair/omni-9.0/qcom.xml workspace/.repo/local_manifests/

- name: Fix busybox bug
if: steps.var.outputs.fix_busybox == 'true'
run: cp repair/omni-9.0/busybox.xml workspace/.repo/local_manifests/

- name: Clone your own device tree
if: steps.var.outputs.use_own_dt == 'true'
run: |
sed -i 's!dt_url!${{ steps.var.outputs.dt_url }}!g' device.xml
sed -i 's!dt_path!${{ steps.var.outputs.dt_path }}!g' device.xml
sed -i 's!dt_remote!${{ steps.var.outputs.dt_remote }}!g' device.xml
sed -i 's!dt_branch!${{ steps.var.outputs.dt_branch }}!g' device.xml
cp device.xml workspace/.repo/local_manifests/
- name: Repo sync
run: |
PATH=~/bin:$PATH
cd workspace
repo sync -c -j$(nproc --all) --force-sync --no-clone-bundle --no-tags
ls -al
- name: Fix cannot locate product
if: steps.var.outputs.fix_product == 'true'
run: |
cd ${{ steps.pwd.outputs.pwd }}/build/core
rm -rf product_config.mk
sed -i 's!device_code!${{ steps.var.outputs.device_code }}!g' ${{ steps.pwd.outputs.pwd }}/../build/core/${{ steps.var.outputs.fix_branch }}/product_config.mk
cp ${{ steps.pwd.outputs.pwd }}/../build/core/${{ steps.var.outputs.fix_branch }}/product_config.mk ${{ steps.pwd.outputs.pwd }}/build/core/product_config.mk
- name: Start Building
run: |
PATH=~/bin:$PATH
cd ${{ steps.pwd.outputs.pwd }}
tree device
export ALLOW_MISSING_DEPENDENCIES=true
source build/envsetup.sh
lunch omni_${{ steps.var.outputs.device_code }}-eng
mka recoveryimage -j$(nproc --all)
- name: Upload REC
uses: softprops/action-gh-release@v1
with:
files: workspace/out/target/product/${{ steps.var.outputs.device_code }}/recovery.img
name: ${{ steps.var.outputs.date }} ${{ steps.var.outputs.device_code }} by ${{ steps.var.outputs.git_username }}
tag_name: ${{ github.run_id }}
body: Android Third-Party Recovery built by ${{ steps.var.outputs.git_username }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<h1 align="center"> 利用Github Actions编译REC</h1>

<div align="center">
<a href="../..">
<img src="demo.jpg" title="Demo" />
</a>
</div>

---

<p align="center">
A Github Action to build Recovery
</p>

<div align="center">
<a href="../../actions">
<img src="../../workflows/rec-building/badge.svg" title="Building Status" />
</a>
</div>

<br />

由于编译时间较长,建议把<code>[.github/workflows/actions_recovery.yml](.github/workflows/actions_recovery.yml)</code>末尾上传处的`${{ secrets.GITHUB_TOKEN }}`改成自己的[Personal Access Token](https://github.com/settings/tokens)

注意保护自己的Personal Access Token,将它放入仓库[Settings](../../settings)里的[Secrets](../../settings/secrets)里后用`${{ secrets.YOUR_TOKEN_NAME }}`来替换`${{ secrets.GITHUB_TOKEN }}`

比如我的secret名字叫做work.则使用`${{ secrets.work }}`

## 配置

配置文件是[config.json](config.json)

| 名称 | 类型 | 描述 |
| ------------------ | ------- | ------------------------------------------------------------ |
| `twrp_url` | String | Recovery Manifest地址 |
| `twrp_branch` | String | Recovery Manifest分支 |
| `git_username` | String | 您使用Git的用户名 |
| `git_email` | String | 您使用Git的邮箱<sub>(Github可使用`Github ID+Github用户名@users.noreply.github.com`)</sub> |
| `use_own_dt` | Boolean | 指示是否使用个人设备树<sub>(此项为`true`后以下三项起效)</sub> |
| `dt_url` | String | 您使用的设备树的地址<sub>(格式:`USER/REPO`)</sub> |
| `dt_branch` | String | 您使用的设备树的分支 |
| `dt_remote` | String | 您使用设备树的存储库<sub>(如`github/gitlab`)</sub> |
| `dt_path` | String | 指示设备树本地保存位置<sub>(示例`device/huawei/kiwi`)</sub> |
| `device_code` | String | 您将要编译机型的机型代号 |
| `fix_product` | Boolean | 指示是否修复无法找到设备的问题 |
| `fix_branch` | String | 指示修复以上问题所使用的分支 |
| `fix_misscom` | Boolean | 指示是否修复缺少`device/qcom/common`的问题 |
| `fix_busybox` | Boolean | 指示是否修复缺少`busybox`的问题 |

## 开始

Fork此仓库后,点击右上角Star就会开始

## 编译结果
可以在[Release](../../releases)下载
Loading

0 comments on commit d6e8e20

Please sign in to comment.