Files
Meshtastic-Android/.github/workflows/protobufs-bump.yml
T

109 lines
4.4 KiB
YAML

name: Protobufs Bump
# A PR that moves the org.meshtastic:protobufs pin gets one sticky comment saying what the bump carries: the
# upstream PRs merged in between, the .proto delta, and the settings strings android will show differently once
# values/schema_strings.xml is regenerated. The regeneration itself is not done here: the hourly scheduled-updates
# run syncs the file from whatever pin main has and carries it, with the Crowdin upload, in its own PR. Nothing is
# pushed to this branch, so Renovate keeps rebasing and automerging it.
on:
pull_request:
branches: [main]
paths:
- gradle/libs.versions.toml
permissions:
contents: read
pull-requests: write
concurrency:
group: protobufs-bump-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
summarise:
runs-on: ubuntu-26.04
timeout-minutes: 30
# A fork PR gets a read-only token, so the comment could not be posted anyway.
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout PR head
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
filter: 'blob:none'
- name: Read the protobufs pin on both sides
id: pin
env:
BASE_REF: ${{ github.base_ref }}
run: |
line='meshtastic-protobufs = '
old=$(git show "origin/$BASE_REF:gradle/libs.versions.toml" | sed -n "s/^${line}\"\(.*\)\"$/\1/p")
new=$(sed -n "s/^${line}\"\(.*\)\"$/\1/p" gradle/libs.versions.toml)
echo "old=$old" >> "$GITHUB_OUTPUT"
echo "new=$new" >> "$GITHUB_OUTPUT"
if [ "$old" = "$new" ]; then
echo "protobufs pin unchanged ($new); nothing to do"
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "protobufs $old -> $new"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Gradle Setup
if: steps.pin.outputs.changed == 'true'
uses: ./.github/actions/gradle-setup
with:
gradle_encryption_key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
develocity_access_key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
job_summary_pr_comment: 'never'
cache_read_only: 'true'
cache_configuration_cache: 'false'
install_jetbrains_jdk: 'true'
# The sync is run to see what it would change; the result is not committed here.
- name: Preview the schema strings at the new pin
if: steps.pin.outputs.changed == 'true'
run: |
cp core/resources/src/commonMain/composeResources/values/schema_strings.xml /tmp/schema_strings.before.xml
./gradlew :schema-strings:sync -Pci=true
cp core/resources/src/commonMain/composeResources/values/schema_strings.xml /tmp/schema_strings.after.xml
git checkout -- core/resources/src/commonMain/composeResources/values/schema_strings.xml
- name: Clone protobufs at both commits
if: steps.pin.outputs.changed == 'true'
run: git clone --filter=blob:none --quiet https://github.com/meshtastic/protobufs.git /tmp/protobufs
- name: Write the summary
if: steps.pin.outputs.changed == 'true'
env:
OLD_PIN: ${{ steps.pin.outputs.old }}
NEW_PIN: ${{ steps.pin.outputs.new }}
run: |
python3 scripts/protobufs-bump-summary.py "$OLD_PIN" "$NEW_PIN" \
--protobufs /tmp/protobufs \
--before /tmp/schema_strings.before.xml \
--after /tmp/schema_strings.after.xml \
> /tmp/summary.md
{
echo
echo "_values/schema_strings.xml is regenerated by the hourly scheduled-updates run after this merges._"
} >> /tmp/summary.md
cat /tmp/summary.md >> "$GITHUB_STEP_SUMMARY"
- name: Post or refresh the sticky comment
if: steps.pin.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
existing=$(gh api "repos/$REPO/issues/$PR/comments" --paginate \
--jq '.[] | select(.body | startswith("<!-- protobufs-bump-summary -->")) | .id' | head -n1)
if [ -n "$existing" ]; then
gh api --method PATCH "repos/$REPO/issues/comments/$existing" -F body=@/tmp/summary.md > /dev/null
else
gh pr comment "$PR" --body-file /tmp/summary.md
fi