Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajal4414 committed Apr 16, 2024
1 parent 9434279 commit a474be0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 64 deletions.
84 changes: 44 additions & 40 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
name: Extract and Release

on:
workflow_dispatch:
inputs:
ROM_URL:
description: "ROM_URL"
default: "https://pixeldrain.com/api/file/WdArNVpq"
DEVICE_NAME:
description: "DEVICE_NAME"
default: "spes"
EXTRACTED_FILES:
description: "EXTRACTED_FILES"
default: "boot.img, dtbo.img, product.img, system.img, system_ext.img"
workflow_dispatch:
inputs:
ROM_URL:
description: "ROM_URL"
default: "https://sourceforge.net/projects/redznn-builds/files/spes/lineage-21.0-20240411-UNOFFICIAL-spes.zip/download"
DEVICE_NAME:
description: "DEVICE_NAME"
default: "spes"
EXTRACTED_FILES:
description: "EXTRACTED_FILES"
default: "boot.img, dtbo.img, product.img, system.img, system_ext.img"

jobs:
build-and-release:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v3
build-and-release:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download file
run: curl -LJO ${{ github.event.inputs.ROM_URL }}
- name: Download file
run: curl -LJO ${{ github.event.inputs.ROM_URL }}

- name: Extract Payload
run: |
chmod u+x .github/scripts/android-ota-extractor
.github/scripts/android-ota-extractor *.zip
echo -e "\n\e[31mDeleting files larger than 2GB...\e[0m"
find . -maxdepth 1 -type f -size +2G -print -delete
echo "ZIP_FILE=$(basename -a *.zip)" >> $GITHUB_ENV
echo "ZIP_FILE_SHA256=$(sha256sum *.zip | cut -d' ' -f1)" >> $GITHUB_ENV
- name: Extract Payload
run: |
chmod u+x .github/scripts/android-ota-extractor
.github/scripts/android-ota-extractor *.zip
while IFS= read -r file; do
file_size=$(du -b "$file" | awk '{print $1}')
if [ $file_size -gt 2147483648 ]; then
echo "Deleting $file"
rm "$file"
fi
echo "ZIP_FILE=$(basename -a *.zip)" >> $GITHUB_ENV
echo "ZIP_FILE_SHA256=$(sha256sum *.zip | cut -d' ' -f1)" >> $GITHUB_ENV
- name: Upload to Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ github.event.inputs.EXTRACTED_FILES }}
name: ${{ github.event.inputs.DEVICE_NAME }}-${{ github.run_id }}
tag_name: ${{ github.run_id }}
body: |
Device: ${{ github.event.inputs.DEVICE_NAME }}
Filename: [${{ env.ZIP_FILE }}](${{ github.event.inputs.ROM_URL }})
Extracted files: ${{ github.event.inputs.EXTRACTED_FILES }}
SHA256: ${{ env.ZIP_FILE_SHA256 }}
- name: Upload to Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ github.event.inputs.EXTRACTED_FILES }}
name: ${{ github.event.inputs.DEVICE_NAME }}-${{ github.run_id }}
tag_name: ${{ github.run_id }}
body: |
Device: ${{ github.event.inputs.DEVICE_NAME }}
Filename: [${{ env.ZIP_FILE }}](${{ github.event.inputs.ROM_URL }})
Extracted files: ${{ github.event.inputs.EXTRACTED_FILES }}
SHA256: ${{ env.ZIP_FILE_SHA256 }}
55 changes: 31 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,45 @@
This GitHub Actions workflow allows you to automatically extract and release specific files from a ROM URL.

## Inputs

The following inputs are required when triggering the workflow:

- `ROM_URL`: The URL of the ROM file to be extracted and released.
- `DEVICE_NAME`: The name of the device for which the ROM is intended.
- `ROM_NAME`: The name of the ROM.
- `EXTRACTED_FILES`: A comma-separated list of files to be extracted from the ROM and included in the release. Available files may include:

- "boot.img" - The boot image, which contains the kernel and recovery.
- "dtbo.img" - The device tree binary image, which contains information about the device's hardware.
- "product.img" - The product image, which contains the system's product-specific properties.
- "system.img" - The system image, which contains the system partition.
- "system_ext.img" - The system_ext image, which contains the system_ext partition.
- "vbmeta.img" - The vbmeta image, which contains verified boot metadata.
- "vbmeta_system.img" - The vbmeta_system image, which contains verified boot metadata for the system partition.
- "vendor.img" - The vendor image, which contains the vendor partition.
- "vendor_boot.img" - The vendor boot image, which contains the vendor-specific kernel and ramdisk.
- `ROM_URL`: The URL of the ROM file to be extracted and released.
- `DEVICE_NAME`: The name of the device for which the ROM is intended.
- `EXTRACTED_FILES`: A comma-separated list of files to be extracted from the ROM and included in the release. Available files may include:

- "boot.img" - The boot image, which contains the kernel and recovery.
- "dtbo.img" - The device tree binary image, which contains information about the device's hardware.
- "product.img" - The product image, which contains the system's product-specific properties.
- "system.img" - The system image, which contains the system partition.
- "system_ext.img" - The system_ext image, which contains the system_ext partition.
- "vbmeta.img" - The vbmeta image, which contains verified boot metadata.
- "vbmeta_system.img" - The vbmeta_system image, which contains verified boot metadata for the system partition.
- "vendor.img" - The vendor image, which contains the vendor partition.
- "vendor_boot.img" - The vendor boot image, which contains the vendor-specific kernel and ramdisk.

## Steps

The workflow is composed of the following steps:

1. Checkout code: check out the repository code.
2. Download file: download the file specified by the ROM_URL input.
3. Unzip file: unzip the downloaded file to a directory named "extracted_files/".
4. Setup Python: set up a version of Python.
5. Install OTA Extractor: download and install the OTA Extractor package.
6. Extract Payload: extract payload from the downloaded file and output it to the current directory.
7. Upload to Release: upload the specified files (EXTRACTED_FILES input) to a GitHub release with a name that includes the DEVICE_NAME and run_id, a tag with the run_id, and a body that includes information about the device, ROM, and extracted files.
1. Checkout code: Check out the repository code.
2. Download file: Download the file specified by the ROM_URL input.
3. Extract Payload: Extract the payload from the downloaded file and output it to the current directory. Additionally, files larger than 2GB will be automatically deleted to comply with GitHub release restrictions, as files larger than 2GB are not allowed.
4. Upload to Release: Uploads specified files to a GitHub release.

## Usage
To use this workflow, create a new GitHub Actions workflow in your repository and copy the contents of [main.yml](https://github.com/your-repo/main.yml) into the file. Update the inputs with your desired values, and configure any necessary secrets. You can then trigger the workflow manually using the "workflow_dispatch" event.

1. Fork this repository to your GitHub account.
2. Go to the "Actions" tab in your forked repository.
3. Enable GitHub Actions for the repository if it's not already enabled.
4. Select the workflow named "Extract and Release" from the list of workflows.
5. Click on the "Run workflow" dropdown button and select the "Run workflow" option.
6. Enter the required inputs:
- `ROM_URL`: The URL of the ROM file to be extracted and released.
- `DEVICE_NAME`: The name of the device for which the ROM is intended.
- `EXTRACTED_FILES`: A comma-separated list of files to be extracted from the ROM and included in the release (e.g., "boot.img, dtbo.img, product.img").
7. Click the "Run workflow" button to trigger the workflow with the provided inputs.

## Note
The OTA Extractor package that is used in this workflow is taken from https://github.com/sakshiagrwal/OTAExtractor, it is cloned, a specific version of protobuf library is installed, and `HEAD~1` is reset to avoid breaking changes. So you can be sure that the package version you are using is compatible with the script.

Additionally, it is important to note that in order to use the `Upload to Release` step, you need to have the `GITHUB_TOKEN` available as a secret in your repository.
The OTA Extractor package that is used in this workflow is taken from https://github.com/tobyxdd/android-ota-payload-extractor.

0 comments on commit a474be0

Please sign in to comment.