Skip to content

Commit b9b8ded

Browse files
committed
feat: read root config from env.toml
Add `ROOT` and `MAGISK_PREINIT` as plain env.toml keys, mapped to the internal variables in check_toml_env. The values only apply when the keys are present in the file, ambient environment variables with the same names do not leak in. Scheduled runs now honor them: the env.toml step exports both, and every root-aware workflow step resolves `inputs || env`, so manual inputs keep precedence and forks can schedule rooted builds. The preinit guard moves after the env.toml read to fail early on schedule as well. Rootless stays the default everywhere. Requested in #351. Assisted-by: Claude Fable 5 Signed-off-by: PiX <69745008+pixincreate@users.noreply.github.com>
1 parent 3204a6a commit b9b8ded

4 files changed

Lines changed: 33 additions & 17 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ jobs:
6868
permissions: write-all
6969

7070
steps:
71-
- name: Check if `magisk-preinit-device` is set when `root` is true
72-
run: |
73-
# Convert inputs to proper boolean values
74-
root="${{ inputs.root }}"
75-
magisk_preinit_device="${{ inputs.magisk-preinit-device }}"
76-
77-
# Ensure that the boolean comparison is correctly handled
78-
if [ "$root" == "true" ] && [ -z "$magisk_preinit_device" ]; then
79-
echo -e "::error:: magisk-preinit-device is required when root is true."
80-
exit 1
81-
fi
82-
8371
- name: Checkout code
8472
uses: actions/checkout@v7
8573
with:
@@ -95,6 +83,21 @@ jobs:
9583
echo "DEVICE_NAME=${DEVICE_NAME}" >> $GITHUB_ENV
9684
echo "GRAPHENEOS_UPDATE_CHANNEL=${GRAPHENEOS[UPDATE_CHANNEL]}" >> $GITHUB_ENV
9785
echo "FORCE_UPDATE=${FORCE_UPDATE:-false}" >> $GITHUB_ENV
86+
# Let scheduled runs build rooted OTAs when env.toml enables it
87+
echo "ROOT=${ADDITIONALS[ROOT]}" >> $GITHUB_ENV
88+
echo "MAGISK_PREINIT=${MAGISK[PREINIT]}" >> $GITHUB_ENV
89+
90+
- name: Check if `magisk-preinit-device` is set when `root` is true
91+
run: |
92+
# Inputs win on manual runs, env.toml supplies the values on schedule
93+
root="${{ inputs.root || env.ROOT }}"
94+
magisk_preinit_device="${{ inputs.magisk-preinit-device || env.MAGISK_PREINIT }}"
95+
96+
# Ensure that the boolean comparison is correctly handled
97+
if [ "$root" == "true" ] && [ -z "$magisk_preinit_device" ]; then
98+
echo -e "::error:: magisk-preinit-device is required when root is true."
99+
exit 1
100+
fi
98101
99102
- name: Set GrapheneOS version
100103
shell: bash
@@ -114,7 +117,7 @@ jobs:
114117
if: github.event_name == 'schedule' || inputs.release-type == 'default'
115118
env:
116119
REPOSITORY: ${{ github.repository }}
117-
ROOT: ${{ inputs.root }}
120+
ROOT: ${{ inputs.root || env.ROOT }}
118121
run: src/ci/check_existing_build.sh
119122

120123
- name: Setup Git
@@ -150,9 +153,9 @@ jobs:
150153
- name: Patch OTA
151154
shell: bash
152155
env:
153-
ADDITIONALS_ROOT: ${{ inputs.root }}
156+
ADDITIONALS_ROOT: ${{ inputs.root || env.ROOT }}
154157
CLEANUP: true
155-
MAGISK_PREINIT: ${{ inputs.magisk-preinit-device }}
158+
MAGISK_PREINIT: ${{ inputs.magisk-preinit-device || env.MAGISK_PREINIT }}
156159
PASSPHRASE_AVB: ${{ secrets.PASSPHRASE_AVB }}
157160
PASSPHRASE_OTA: ${{ secrets.PASSPHRASE_OTA }}
158161
run: |
@@ -189,13 +192,13 @@ jobs:
189192
env:
190193
GH_TOKEN: ${{ github.token }}
191194
REPOSITORY: ${{ github.repository }}
192-
ROOT: ${{ inputs.root }}
195+
ROOT: ${{ inputs.root || env.ROOT }}
193196
run: src/ci/remove_superseded_assets.sh
194197

195198
- name: Publish OTA to server
196199
shell: bash
197200
if: inputs.release-type != 'build-only'
198201
env:
199202
RELEASE_TYPE: ${{ inputs.release-type }}
200-
ROOT: ${{ inputs.root }}
203+
ROOT: ${{ inputs.root || env.ROOT }}
201204
run: src/ci/publish_ota.sh

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ Configuration is layered.
273273
In CI, `env.toml` is read only on scheduled runs.
274274
Manual runs take all values from the workflow inputs.
275275
Forks set `GITHUB_USER` and `GITHUB_REPO` in `env.toml` so `src/declarations.sh` stays untouched.
276+
Scheduled runs also read `ROOT` and `MAGISK_PREINIT` from `env.toml`, so a fork can build rooted OTAs on schedule.
276277

277278
To make the patched OTA available to the device, it needs to be hosted on the server. PixeneOS uses GitHub for pushing updates, handled by [release.yml](.github/workflows/release.yml).
278279

env.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ FORCE_UPDATE = "false"
1111
# ARCH = "x86_64-unknown-linux-gnu"
1212
# Disable a bundled module, for example BCR
1313
# 'ADDITIONALS[BCR]' = "false"
14+
# Add root to local and scheduled builds. Requires MAGISK_PREINIT
15+
# ROOT = "true"
16+
# Magisk preinit device for your device, for example "sda8"
17+
# MAGISK_PREINIT = "sda8"
1418

1519
[github]
1620
# Set these when running a fork, used for the OTA server URL

src/util_functions.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,14 @@ function check_toml_env() {
486486
# printf -v keeps values with spaces or commas intact, eval would split them
487487
printf -v "${key}" '%s' "${config_vars[$key]}"
488488
done
489+
490+
# `ROOT` and `MAGISK_PREINIT` are friendly aliases for the internal variables
491+
if [[ -n "${config_vars[ROOT]:-}" ]]; then
492+
ADDITIONALS[ROOT]="${config_vars[ROOT]}"
493+
fi
494+
if [[ -n "${config_vars[MAGISK_PREINIT]:-}" ]]; then
495+
MAGISK[PREINIT]="${config_vars[MAGISK_PREINIT]}"
496+
fi
489497
else
490498
error "Failed to find the required variables in \`${toml_file}\`.\n"
491499
exit 1

0 commit comments

Comments
 (0)