ci: add action for bumping platform repos

This commit is contained in:
jj
2025-08-29 13:03:10 +00:00
parent 5480886df1
commit 7b69063b6e

View File

@@ -0,0 +1,90 @@
name: Bump platform revision
description: Refreshes patches, updates the platform revision and submodule
inputs:
token:
description: 'GitHub access token'
required: true
runs:
using: composite
steps:
- name: Prepare
shell: bash
run: sudo apt install quilt
- name: Bump revision and make PR
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
set -euxo pipefail
PLATFORM_DIR="$PWD"
HELIUM_DIR="$PLATFORM_DIR/helium-chromium"
run_upstream() {
python3 "$HELIUM_DIR/$1" "${@:2}"
}
get_version() {
run_upstream utils/helium_version.py \
--tree "$HELIUM_DIR" \
--platform-tree "$PLATFORM_DIR" \
--print
}
# get versions and compare them after submodule update
version_before=$(get_version)
pushd "$HELIUM_DIR"
git fetch origin main
git checkout origin/main
popd
git switch update || git switch -c update
version_after=$(get_version)
# reset or bump revision counter depending on version change
if [ "$version_before" != "$version_after" ]; then
echo "main version changed, resetting platform revision"
echo 1 > "$PLATFORM_DIR/revision.txt"
else
echo "no change in main version, bumping platform revision"
revision=$(cat "$PLATFORM_DIR/revision.txt")
echo $((revision + 1)) > "$PLATFORM_DIR/revision.txt"
fi
version_after=$(get_version)
mkdir -p build/{src,download_cache}
# fetch soures, expect that patches apply cleanly (or die)
run_upstream utils/downloads.py retrieve \
-i "$HELIUM_DIR/downloads.ini" -c build/download_cache
run_upstream utils/downloads.py unpack \
-i "$HELIUM_DIR/downloads.ini" -c build/download_cache build/src
run_upstream utils/patches.py apply \
--no-fuzz build/src "$HELIUM_DIR/patches"
# refresh platform patches if necessary
source "$HELIUM_DIR/devutils/set_quilt_vars.sh"
export QUILT_PATCHES="$PLATFORM_DIR/patches"
pushd build/src
quilt --quiltrc - push -a --refresh
popd
# commit, push, make pr
TITLE="update: helium-chromium $version_after"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -u patches helium-chromium revision.txt
if ! git status | tail -1 | grep -q 'nothing to commit'; then
git commit -m "$TITLE"
git push origin update
gh pr create --title "$TITLE" --body "" || :
fi