RisingOS Build for realme RM6785 [userdebug, test & GAPPS] #196
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: RisingOS Builder | |
on: | |
workflow_dispatch: | |
inputs: | |
BRAND: | |
description: 'Put your device manufacturer name please.' | |
required: true | |
CODENAME: | |
description: 'Put your device codename please.' | |
required: true | |
SIGNING: | |
description: 'The build signing. Set to "normal" by default.' | |
required: true | |
default: 'normal' | |
type: choice | |
options: | |
- 'full' | |
- 'normal' | |
- 'normal-fastboot' | |
TYPE: | |
description: 'The build type. Set to "userdebug" by default.' | |
required: true | |
default: 'userdebug' | |
type: choice | |
options: | |
- 'eng' | |
- 'user' | |
- 'userdebug' | |
RELEASE: | |
description: 'The build target. Set to "stable" by default.' | |
required: true | |
default: 'stable' | |
type: choice | |
options: | |
- 'test' | |
- 'stable' | |
VARIANT: | |
description: 'If you wanna build other variants like vanilla, core or gapps.' | |
required: false | |
default: 'CORE' | |
type: choice | |
options: | |
- 'VANILLA' | |
- 'CORE' | |
- 'GAPPS' | |
permissions: | |
actions: write | |
contents: write | |
statuses: write | |
run-name: "RisingOS Build for ${{ inputs.BRAND }} ${{ inputs.CODENAME }} [${{ inputs.TYPE }}, ${{ inputs.RELEASE }} & ${{ inputs.VARIANT }}]" | |
jobs: | |
check-limit: | |
runs-on: ubuntu-latest | |
outputs: | |
staging: ${{ steps.get_role.outputs.is_staging_member }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get User Role | |
id: get_role | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN }} | |
run: | | |
OWNERS=$(gh api -H "Accept: application/vnd.github+json" /orgs/RisingOSS-devices/members?role=admin --jq '.[].login') | |
STAGING_MEMBERS=$(gh api -H "Accept: application/vnd.github+json" /orgs/RisingOS-staging/members --jq '.[].login') | |
DEVICES_MEMBERS=$(gh api -H "Accept: application/vnd.github+json" /orgs/RisingOSS-devices/members --jq '.[].login') | |
is_owner=$(echo "$OWNERS" | grep -q "${{ github.actor }}" && echo "true" || echo "false") | |
is_staging_member=$(echo "$STAGING_MEMBERS" | grep -q "${{ github.actor }}" && echo "true" || echo "false") | |
is_devices_member=$(echo "$DEVICES_MEMBERS" | grep -q "${{ github.actor }}" && echo "true" || echo "false") | |
echo "is_owner=$is_owner" >> $GITHUB_ENV | |
echo "is_staging_member=$is_staging_member" >> $GITHUB_ENV | |
echo "is_devices_member=$is_devices_member" >> $GITHUB_ENV | |
echo "is_owner=$is_owner" >> $GITHUB_OUTPUT | |
echo "is_staging_member=$is_staging_member" >> $GITHUB_OUTPUT | |
echo "is_devices_member=$is_devices_member" >> $GITHUB_OUTPUT | |
- name: Check Builds Limit | |
id: check_limit | |
run: | | |
COUNTER_FILE=".github/workflow_counter.json" | |
CURRENT_DATE=$(date +%Y-%m-%d) | |
DEVICE=${{ inputs.CODENAME }} | |
if [[ ! -f "$COUNTER_FILE" ]] || ! jq empty "$COUNTER_FILE" 2>/dev/null; then | |
echo '{}' > "$COUNTER_FILE" | |
fi | |
TODAY_RUNS=$(jq -r --arg device "$DEVICE" --arg date "$CURRENT_DATE" \ | |
'if .[$device][$date] then .[$device][$date] else 0 end' "$COUNTER_FILE") | |
if [[ ! "$TODAY_RUNS" =~ ^[0-9]+$ ]]; then | |
TODAY_RUNS=0 | |
fi | |
echo "Today's runs for device $DEVICE: $TODAY_RUNS" | |
if [[ "${{ env.is_owner }}" == "true" ]]; then | |
LIMIT=-1 | |
elif [[ "${{ env.is_staging_member }}" == "true" ]]; then | |
LIMIT=5 | |
else | |
LIMIT=3 | |
fi | |
if [[ $LIMIT -ne -1 && "$TODAY_RUNS" -ge $LIMIT ]]; then | |
echo "Device $DEVICE has reached the daily limit of $LIMIT workflow runs." | |
exit 1 | |
fi | |
NEW_RUNS=$((TODAY_RUNS + 1)) | |
jq --arg device "$DEVICE" --arg date "$CURRENT_DATE" --argjson runs "$NEW_RUNS" \ | |
'del(.[$device]) | .[$device][$date] = $runs' "$COUNTER_FILE" > tmp.json && mv tmp.json "$COUNTER_FILE" | |
echo "Updated run count for device $DEVICE: $NEW_RUNS" | |
- name: Commit and push counter update | |
run: | | |
COUNTER_FILE=".github/workflow_counter.json" | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add $COUNTER_FILE | |
git commit -m "Update workflow run count for device ${{ inputs.CODENAME }}" | |
git push | |
if: steps.check_limit.outcome == 'success' | |
build: | |
needs: check-limit | |
runs-on: self-hosted | |
env: | |
USER: sketu | |
BRAND: ${{ inputs.BRAND }} | |
CODENAME: ${{ inputs.CODENAME }} | |
SIGNING: ${{ inputs.SIGNING }} | |
TYPE: ${{ inputs.TYPE }} | |
RELEASE: ${{ inputs.RELEASE }} | |
VARIANT: ${{ inputs.VARIANT }} | |
STAGING: ${{ needs.check-limit.outputs.staging }} | |
SF_HOST: ${{ secrets.SF_HOST }} | |
SF_USERNAME: ${{ secrets.SF_USERNAME }} | |
SF_PASSWORD: ${{ secrets.SF_PASSWORD }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Init and Sync | |
run: bash resync.sh | |
- name: Clone Repositories | |
run: | | |
mkdir -p /home/sketu/rising/vendor/lineage-priv/ | |
cp -r /home/sketu/keys /home/sketu/rising/vendor/lineage-priv/keys/ | |
bash clone.sh | |
- name: Set flags | |
run: bash misc/flags.sh | |
- name: Build RisingOS | |
run: bash build.sh | |
- name: Upload Error Log | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: error-log | |
path: /home/sketu/rising/out/error.log | |
- name: Upload Build JSON | |
if: success() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-json | |
path: /home/sketu/rising/out/target/product/*/*${{ inputs.CODENAME }}.json | |
- name: Upload Build Files | |
run: bash upload.sh | |
- name: Post-Cleanup | |
if: ${{ always() }} | |
run: bash clean.sh |