Crave Builder #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build ROMs Using Crave | ||
on: | ||
workflow_dispatch: | ||
# Various inputs to simplify usage of workflow. | ||
inputs: | ||
BASE_PROJECT: | ||
description: 'Choose a base project:' | ||
required: true | ||
default: 'LineageOS 20.0' | ||
type: choice | ||
options: | ||
- 'LineageOS 20.0' | ||
- 'crDroid 14.0' | ||
- 'ArrowOS 13.1' | ||
- 'DerpFest 13.0' | ||
SOURCE_MANIFEST: | ||
description: "Different AOSP source for 'repo' (manifest):" | ||
required: false | ||
default: | ||
SOURCE_BRANCH: | ||
description: "Different source for 'repo' (rbranch):" | ||
required: false | ||
default: | ||
REMOVALS: | ||
description: "Folders to be removed before syncing:" | ||
required: false | ||
LOCAL_MANIFEST: | ||
description: "Personal local manifest [repository or raw]:" | ||
required: true | ||
default: 'https://github.com/sounddrill31/local_manifests' | ||
LOCAL_MANIFEST_BRANCH: | ||
description: "Personal local manifest's branch:" | ||
required: false | ||
default: 'lineage-oxygen' | ||
DEVICE_NAME: | ||
description: "Device's codename:" | ||
required: true | ||
default: "oxygen" | ||
BUILD_COMMAND: | ||
description: 'Command to be used for compiling:' | ||
required: true | ||
default: 'mka bacon' | ||
BUILD_TYPE: | ||
description: 'Type of build:' | ||
required: true | ||
default: 'userdebug' | ||
type: choice | ||
options: | ||
- 'eng' | ||
- 'userdebug' | ||
- 'user' | ||
CLEAN_BUILD: | ||
description: 'Build with a clean workspace?' | ||
required: true | ||
default: 'no' | ||
type: choice | ||
options: | ||
- 'yes' | ||
- 'no' | ||
jobs: | ||
test: | ||
name: Build using foss.crave.io | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Clean the workflow before initialization. | ||
- name: Cleanup | ||
run: rm -rf ${PWD}/* | ||
# Check-out in order to access the repository's files. | ||
- name: Check-out to repository | ||
uses: actions/checkout@v4 | ||
# Set-up a spearate directory for the device. | ||
- name: Set-up wokrspace environment | ||
run: | | ||
mkdir ${{ github.event.inputs.DEVICE_NAME }} | ||
cd ${{ github.event.inputs.DEVICE_NAME }} | ||
continue-on-error: true | ||
# Download and configure 'repo'. | ||
- name: Configure the 'repo' environment | ||
run: | | ||
mkdir "${HOME}/bin" | ||
curl https://storage.googleapis.com/git-repo-downloads/repo >> "${HOME}/bin/repo" | ||
chmod a+x "${HOME}/bin/repo" | ||
sudo ln -sf "/home/${USER}/bin/repo" "/usr/bin/repo" | ||
# Generate 'git' credential in base of the workflow's author. | ||
- name: Set-up 'git' credential(s) | ||
run: | | ||
git config --global user.name "${{ github.actor }}" | ||
git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | ||
# Initialize the previously choosen 'repo' project. | ||
- name: Configure the 'repo' environment | ||
run: | | ||
case "${{ github.event.inputs.BASE_PROJECT }}" in | ||
"ArrowOS 13.1") | ||
repo init -u https://github.com/ArrowOS/android_manifest.git -b arrow-13.1 --depth=1 | ||
;; | ||
"DerpFest 13.0") | ||
repo init -u https://github.com/DerpFest-AOSP/manifest.git -b 13 --depth=1 | ||
;; | ||
"crDroid 14.0") | ||
repo init -u https://github.com/crdroidandroid/android.git -b 14.0 --git-lfs --depth=1 | ||
;; | ||
"LineageOS 20.0") | ||
repo init -u https://github.com/LineageOS/android.git -b lineage-20.0 --git-lfs --depth=1 | ||
;; | ||
esac | ||
id: pwd | ||
# Download and configure 'crave'. | ||
- name: Configure the 'crave' environment | ||
run: | | ||
curl -s https://raw.githubusercontent.com/accupara/crave/master/get_crave.sh | bash -s -- | ||
mv ${PWD}/crave ${HOME}/bin/ | ||
sudo ln -sf /home/${USER}/bin/crave /usr/bin/crave | ||
envsubst < ${PWD}/crave.conf.sample >> ${PWD}/crave.conf | ||
rm -rf ${PWD}/crave.conf.sample | ||
env: | ||
CRAVE_USERNAME: ${{ secrets.CRAVE_USERNAME }} | ||
CRAVE_TOKEN: ${{ secrets.CRAVE_TOKEN }} | ||
# Export the product target. | ||
- name: Setting build product target | ||
run: | | ||
# Create a 'crave' job for building. | ||
- name: Start compilation through 'crave' | ||
run: | | ||
Check failure on line 134 in .github/workflows/main.yml GitHub Actions / Build ROMs Using CraveInvalid workflow file
|
||
if [ "${{ github.event.inputs.CLEAN_BUILD }}" == "yes" ]; then | ||
export CLEAN="clean" | ||
fi | ||
# Start the building node | ||
crave run --no-patch --${CLEAN} "rm -rf ${{ github.event.inputs.REMOVALS }} && \ | ||
# Set-up 'repo' for different ROM manifest | ||
if [ -z ${{ github.event.inputs.SOURCE_MANIFEST }} ]; then \ | ||
if [ -z ${{ github.event.inputs.SOURCE_BRANCH }} ]; then \ | ||
repo init -u ${{ github.event.inputs.SOURCE_MANIFEST --git-lfs --depth=1; \ | ||
else \ | ||
repo init -u ${{ github.event.inputs.SOURCE_MANIFEST -b ${{ github.event.inputs.SOURCE_BRANCH }} --git-lfs --depth=1 | ||
fi \ | ||
# Clone local_manifests repository | ||
git clone ${{ github.event.inputs.LOCAL_MANIFEST }} --depth 1 -b ${{ github.event.inputs.LOCAL_MANIFEST_BRANCH }} .repo/local_manifests && \ | ||
if [ ! $? == 0 ]; then \ | ||
curl -o .repo/local_manifests ${{ github.event.inputs.LOCAL_MANIFEST }}; \ | ||
fi \ | ||
# Set the build product target | ||
PRODUCT_TARGET="$(find device/*/${{ github.event.inputs.DEVICE_NAME }})" | ||
# Sync the repositories | ||
repo sync -c -j$(nproc --all) --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync && \ | ||
# Set up build environment | ||
export BUILD_USERNAME=${{ github.actor }} ; \ | ||
export BUILD_HOSTNAME=crave ; \ | ||
source build/envsetup.sh && \ | ||
# Build the ROM | ||
lunch ${PRODUCT_TARGET}-${{ github.event.inputs.BUILD_TYPE }} && \ | ||
make clean && \ | ||
${{ github.event.inputs.BUILD_COMMAND }}" | ||
env: | ||
# Only reach this wheter the user killed the workflow. | ||
- name: Execute if the job is cancelled | ||
if: ${{ cancelled() }} | ||
run: crave stop --all | ||
# Pull '.zip's and '.img's from 'crave'. | ||
- name: Retrive build artifact(s) | ||
run: | | ||
crave pull out/target/product/*/*.zip | ||
crave pull out/target/product/*/*.img | ||
# Directly upload to releases. | ||
- name: Upload to repository's releases page | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
${{ github.event.inputs.DEVICE_NAME }}/recovery.img | ||
${{ github.event.inputs.DEVICE_NAME }}/boot.img | ||
${{ github.event.inputs.DEVICE_NAME }}/vendor_boot.img | ||
${{ github.event.inputs.DEVICE_NAME }}/vendor.img | ||
${{ github.event.inputs.DEVICE_NAME }}/system.img | ||
${{ github.event.inputs.DEVICE_NAME }}/*.zip | ||
name: ${{ github.event.inputs.PRODUCT_NAME }}-${{ github.run_id }} | ||
tag_name: ${{ github.run_id }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |